aboutsummaryrefslogtreecommitdiffstats
path: root/cheesemap.c
diff options
context:
space:
mode:
Diffstat (limited to 'cheesemap.c')
-rw-r--r--cheesemap.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/cheesemap.c b/cheesemap.c
index c443593..5e6c124 100644
--- a/cheesemap.c
+++ b/cheesemap.c
@@ -23,3 +23,21 @@ void cm_raw_drop(struct cheesemap_raw* map, uintptr_t entry_size,
uint8_t* origin = cm_raw_origin(map, entry_size);
fns->free(origin, fns->mem_usr);
}
+
+void cm_new(struct cheesemap* map, uintptr_t entry_size,
+ uint8_t* mem_usr, cm_malloc_fn malloc, cm_free_fn free,
+ uint8_t* map_usr, cm_hash_fn hash,
+ cm_compare_fn compare) {
+ assert(map != NULL);
+ assert(malloc != NULL && free != NULL);
+ assert(hash != NULL && compare != NULL);
+
+ struct cheesemap_fns fns = {
+ mem_usr, map_usr, //
+ malloc, free, //
+ hash, compare, //
+ };
+
+ *map = (struct cheesemap){entry_size, fns, cm_raw_new()};
+}
+