style: noming env_utils

This commit is contained in:
Raphael 2024-09-19 15:26:26 +02:00
parent c6f713a6de
commit 7243dd263d

View file

@ -1,12 +1,12 @@
/* ************************************************************************** */ /* ************************************************************************** */
/* */ /* */
/* ::: :::::::: */ /* ::: :::::::: */
/* hashmap_env_utils.c :+: :+: :+: */ /* env_utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */ /* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */ /* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/06 10:58:20 by maiboyer #+# #+# */ /* Created: 2023/12/06 10:58:20 by maiboyer #+# #+# */
/* Updated: 2023/12/11 15:35:37 by maiboyer ### ########.fr */ /* Updated: 2024/09/19 15:26:18 by rparodi ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -16,12 +16,11 @@
#include "me/types.h" #include "me/types.h"
#include <stdlib.h> #include <stdlib.h>
t_str *hmap_env_get(t_hashmap_env *hmap, t_str *hmap_env_get(t_hashmap_env *hmap, t_str *key)
t_str *key)
{ {
t_usize hashed_key; t_usize hashed_key;
t_entry_env *entry; t_entry_env *entry;
t_entry_env *prev; t_entry_env *prev;
hmap->hfunc(&hmap->hasher, key); hmap->hfunc(&hmap->hasher, key);
hashed_key = hasher_reset_and_finish(&hmap->hasher); hashed_key = hasher_reset_and_finish(&hmap->hasher);
@ -31,18 +30,18 @@ t_str *hmap_env_get(t_hashmap_env *hmap,
return (&entry->kv.val); return (&entry->kv.val);
} }
void hmap_env_remove(t_hashmap_env *hmap, t_str *key) void hmap_env_remove(t_hashmap_env *hmap, t_str *key)
{ {
t_usize hashed_key; t_usize hashed_key;
t_entry_env *prev; t_entry_env *prev;
t_entry_env *entry; t_entry_env *entry;
hmap->hfunc(&hmap->hasher, key); hmap->hfunc(&hmap->hasher, key);
hashed_key = hasher_reset_and_finish(&hmap->hasher); hashed_key = hasher_reset_and_finish(&hmap->hasher);
prev = NULL; prev = NULL;
entry = hmap_env_get_entry(hmap, hashed_key, key, &prev); entry = hmap_env_get_entry(hmap, hashed_key, key, &prev);
if (entry == NULL) if (entry == NULL)
return; return ;
if (prev == NULL) if (prev == NULL)
hmap->buckets[hashed_key % hmap->num_buckets] = entry->next; hmap->buckets[hashed_key % hmap->num_buckets] = entry->next;
else else