Put the custom allocator in its own lib, as to lessen the difficulty to switch between libc's allocator and a custom one (#7)

This commit is contained in:
Maix0 2024-05-14 18:56:53 +02:00 committed by GitHub
parent 713f0f0302
commit cb7f3c3fdf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
85 changed files with 1121 additions and 877 deletions

View file

@ -43,7 +43,7 @@ t_hashmap_C__PREFIX__ *new_hashmap_with_buckets_C__PREFIX__(
hmap->cfunc = cfunc;
hmap->drop = drop;
if (hmap->buckets == NULL)
return ((void)me_free(hmap), NULL);
return ((void)mem_free(hmap), NULL);
return (hmap);
}
@ -57,13 +57,13 @@ void drop_hashmap_C__PREFIX__(t_hashmap_C__PREFIX__ *hmap)
if (hmap->buckets[index])
{
hmap->drop(hmap->buckets[index]->kv);
me_free(hmap->buckets[index]);
mem_free(hmap->buckets[index]);
}
index++;
}
hasher_finish(&hmap->hasher);
me_free(hmap->buckets);
me_free(hmap);
mem_free(hmap->buckets);
mem_free(hmap);
}
t_entry_C__PREFIX__ *hashmap_get_entry_C__PREFIX__(t_hashmap_C__PREFIX__ *hmap,

View file

@ -51,6 +51,6 @@ void remove_hashmap_C__PREFIX__(t_hashmap_C__PREFIX__ *hmap, C__KEYTYPE__ *key)
else
prev->next = entry->next;
hmap->drop(entry->kv);
me_free(entry);
mem_free(entry);
hmap->buckets[hashed_key % hmap->num_buckets] = NULL;
}