diff options
| author | Fabrice <fabrice@schaub-dev.xyz> | 2026-03-20 18:08:24 +0100 |
|---|---|---|
| committer | Fabrice <fabrice@schaub-dev.xyz> | 2026-03-20 18:08:24 +0100 |
| commit | 858ae4d03def568a03f53826c31842f24d9c49c0 (patch) | |
| tree | a1965732a59c9f8974f44609ba877a7f8a2bd2b3 /cheesemap.c | |
init
Diffstat (limited to 'cheesemap.c')
| -rw-r--r-- | cheesemap.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/cheesemap.c b/cheesemap.c new file mode 100644 index 0000000..c443593 --- /dev/null +++ b/cheesemap.c @@ -0,0 +1,25 @@ +#include "cheesemap.h" + +#include <stddef.h> + +static inline uintptr_t cm_raw_capacity(const struct cheesemap_raw* map) { + assert(map != NULL); + return map->cap_mask + 1; +} + +static inline uint8_t* cm_raw_origin(const struct cheesemap_raw* map, + uintptr_t entry_size) { + assert(map != NULL); + return map->ctrl - entry_size * cm_raw_capacity(map); +} + +void cm_raw_drop(struct cheesemap_raw* map, uintptr_t entry_size, + struct cheesemap_fns* fns) { + assert(map != NULL); + assert(fns != NULL); + + if (map->ctrl == NULL) return; + + uint8_t* origin = cm_raw_origin(map, entry_size); + fns->free(origin, fns->mem_usr); +} |
