update stuff

This commit is contained in:
Maieul BOYER 2024-08-03 00:00:42 +02:00
parent 24b210fe86
commit 709c124028
No known key found for this signature in database
20 changed files with 176 additions and 64 deletions

View file

@ -19,15 +19,15 @@
t_hashmap_env *hmap_env_new(t_hash_env_fn hfunc,
t_eq_env_fn cfunc,
t_drop_env_fn drop)
t_free_env_fn free)
{
return (
hmap_env_new_with_buckets(hfunc, cfunc, drop, DEFAULT_BUCKETS));
hmap_env_new_with_buckets(hfunc, cfunc, free, DEFAULT_BUCKETS));
}
t_hashmap_env *hmap_env_new_with_buckets(
t_hash_env_fn hfunc, t_eq_env_fn cfunc,
t_drop_env_fn drop, t_usize buckets)
t_free_env_fn free, t_usize buckets)
{
t_hashmap_env *hmap;
@ -39,7 +39,7 @@ t_hashmap_env *hmap_env_new_with_buckets(
hmap->hasher = hasher_sip13_new();
hmap->hfunc = hfunc;
hmap->cfunc = cfunc;
hmap->drop = drop;
hmap->free = free;
if (hmap->buckets == NULL)
return ((void)mem_free(hmap), NULL);
return (hmap);
@ -57,7 +57,7 @@ void hmap_env_free(t_hashmap_env *hmap)
entry = hmap->buckets[index];
while (entry != NULL)
{
hmap->drop(entry->kv);
hmap->free(entry->kv);
tmp = entry->next;
mem_free(entry);
entry = tmp;
@ -117,7 +117,7 @@ bool hmap_env_insert(t_hashmap_env *hmap, t_str key,
}
else
{
hmap->drop(entry->kv);
hmap->free(entry->kv);
entry->kv.key = key;
entry->kv.val = value;
return (true);