commit 8f110e4f4caba424ea5ede2bf9531b9f09c5348e
parent 9ad64c4303484ab9ea82c2f901acf33044ea8a52
Author: Louis Burda <quent.burda@gmail.com>
Date: Sun, 21 May 2023 17:48:31 +0200
Update liballoc
Diffstat:
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/src/hmap.c b/src/hmap.c
@@ -22,7 +22,8 @@ hmap_init(struct hmap *map, size_t size, hmap_hash_func hasher,
map->keycmp = keycmp;
map->bucketcnt = size;
map->hash = hasher;
- map->buckets = map->allocator->alloc(sizeof(void *) * size, &rc);
+ map->buckets = map->allocator->alloc(map->allocator,
+ sizeof(void *) * size, &rc);
if (!map->buckets) return -rc;
memset(map->buckets, 0, size * sizeof(void *));
@@ -36,7 +37,7 @@ hmap_deinit(struct hmap *map)
hmap_clear(map);
- return map->allocator->free(map->buckets);
+ return map->allocator->free(map->allocator, map->buckets);
}
struct hmap *
@@ -50,13 +51,13 @@ hmap_alloc(size_t size, hmap_hash_func hasher,
rc = _rc ? _rc : &stub;
- map = allocator->alloc(sizeof(struct hmap), rc);
+ map = allocator->alloc(allocator, sizeof(struct hmap), rc);
if (!map && _rc) *rc = -*rc;
if (!map) return NULL;
*rc = hmap_init(map, size, hasher, keycmp, allocator);
if (*rc) {
- allocator->free(map);
+ allocator->free(allocator, map);
return NULL;
}
@@ -75,7 +76,7 @@ hmap_free(struct hmap *map)
rc = hmap_deinit(map);
if (rc) return rc;
- rc = allocator->free(map);
+ rc = allocator->free(allocator, map);
if (rc) return -rc;
return 0;
@@ -120,10 +121,10 @@ hmap_clear(const struct hmap *map)
prev = NULL;
for (HMAP_ITER(map, iter)) {
- map->allocator->free(prev);
+ map->allocator->free(map->allocator, prev);
prev = iter.link;
}
- map->allocator->free(prev);
+ map->allocator->free(map->allocator, prev);
for (i = 0; i < map->bucketcnt; i++)
map->buckets[i] = NULL;
@@ -186,7 +187,8 @@ hmap_link_alloc(const struct hmap *map,
LIBHMAP_ABORT_ON_ARGS(!map);
- link = map->allocator->alloc(sizeof(struct hmap_link), rc);
+ link = map->allocator->alloc(map->allocator,
+ sizeof(struct hmap_link), rc);
if (!link && rc) *rc = -*rc;
if (!link) return NULL;
@@ -236,7 +238,7 @@ hmap_rm(const struct hmap *map, struct hmap_key key)
if (!linkp) return HMAP_KEY_MISSING;
link = hmap_link_pop(map, linkp);
- rc = map->allocator->free(link);
+ rc = map->allocator->free(map->allocator, link);
if (rc) return -rc;
return 0;