diff options
| author | Fabrice <fabrice@schaub-dev.xyz> | 2026-04-12 08:32:08 +0200 |
|---|---|---|
| committer | Fabrice <fabrice@schaub-dev.xyz> | 2026-04-12 08:32:08 +0200 |
| commit | 2983e797dde8bafb2e17aafd2cf0981d2d113afb (patch) | |
| tree | ad17914803259cd066109ef4c038e6b307328149 | |
| parent | 676e82fd11f7bab138a7ff64e7e3bc38bddb85ea (diff) | |
fix naming
| -rw-r--r-- | CMakeLists.txt | 1 | ||||
| -rw-r--r-- | cheesemap.c | 16 | ||||
| -rw-r--r-- | cheesemap.h | 20 |
3 files changed, 19 insertions, 18 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index a9ca13d..2f87f41 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,6 +49,7 @@ set_target_properties(cheesemap PROPERTIES C_STANDARD 11 C_STANDARD_REQUIRED ON C_EXTENSIONS ON + POSITION_INDEPENDENT_CODE ON ) ## configuration summary diff --git a/cheesemap.c b/cheesemap.c index 55a139a..c6e7077 100644 --- a/cheesemap.c +++ b/cheesemap.c @@ -357,7 +357,7 @@ static bool cm_raw_resize(struct cheesemap_raw* map, cm_hash_fn hash, cm_assert(alloc != NULL && dealloc != NULL); struct cheesemap_raw new_map; - bool success = cm_raw_new_with(&new_map, alloc, user, type, new_capacity); + bool success = cm_raw_init_with(&new_map, alloc, user, type, new_capacity); if (!success) return false; cm_raw_rehash(map, &new_map, hash, user, type); @@ -367,8 +367,8 @@ static bool cm_raw_resize(struct cheesemap_raw* map, cm_hash_fn hash, return true; } -bool cm_raw_new_with(struct cheesemap_raw* map, cm_alloc_fn alloc, cm_u8* user, - const struct cm_type* type, cm_usize initial_capacity) { +bool cm_raw_init_with(struct cheesemap_raw* map, cm_alloc_fn alloc, cm_u8* user, + const struct cm_type* type, cm_usize initial_capacity) { cm_assert(map != NULL); cm_assert(alloc != NULL); memset(map, 0, sizeof(*map)); @@ -493,10 +493,10 @@ void cm_raw_drop(struct cheesemap_raw* map, cm_dealloc_fn dealloc, cm_u8* user, *map = cm_raw_new(); } -void cm_new(struct cheesemap* map, cm_usize key_size, cm_usize key_align, - cm_usize value_size, cm_usize value_align, cm_u8* user, - cm_hash_fn hash, cm_compare_fn compare, cm_alloc_fn alloc, - cm_dealloc_fn dealloc) { +void cm_init(struct cheesemap* map, cm_usize key_size, cm_usize key_align, + cm_usize value_size, cm_usize value_align, cm_u8* user, + cm_hash_fn hash, cm_compare_fn compare, cm_alloc_fn alloc, + cm_dealloc_fn dealloc) { cm_assert(map != NULL); cm_assert(hash != NULL && compare != NULL); cm_assert(alloc != NULL && dealloc != NULL); @@ -507,7 +507,7 @@ void cm_new(struct cheesemap* map, cm_usize key_size, cm_usize key_align, struct cm_type type = cm_type_new(key_size, value_size, value_offset, entry_size); - *map = cm_new_raw(type, user, hash, compare, alloc, dealloc, cm_raw_new()); + *map = cm_init_inner(type, user, hash, compare, alloc, dealloc, cm_raw_new()); } void cm_drop(struct cheesemap* map) { diff --git a/cheesemap.h b/cheesemap.h index f7353d1..338fd8a 100644 --- a/cheesemap.h +++ b/cheesemap.h @@ -124,8 +124,8 @@ struct cheesemap_raw { #define cm_raw_new() \ ((struct cheesemap_raw){.ctrl = (cm_u8*)CM_CTRL_STATIC_EMPTY}) -bool cm_raw_new_with(struct cheesemap_raw* map, cm_alloc_fn alloc, cm_u8* user, - const struct cm_type* type, cm_usize initial_capacity); +bool cm_raw_init_with(struct cheesemap_raw* map, cm_alloc_fn alloc, cm_u8* user, + const struct cm_type* type, cm_usize initial_capacity); void cm_raw_drop(struct cheesemap_raw* map, cm_dealloc_fn dealloc, cm_u8* user, const struct cm_type* type); bool cm_raw_reserve(struct cheesemap_raw* map, cm_hash_fn hash, @@ -158,13 +158,13 @@ struct cheesemap { struct cheesemap_raw raw; }; -#define cm_new_raw(type, user, hash, compare, alloc, dealloc, raw) \ +#define cm_init_inner(type, user, hash, compare, alloc, dealloc, raw) \ ((struct cheesemap){type, user, hash, compare, alloc, dealloc, raw}) -void cm_new(struct cheesemap* map, cm_usize key_size, cm_usize key_align, - cm_usize value_size, cm_usize value_align, cm_u8* user, - cm_hash_fn hash, cm_compare_fn compare, cm_alloc_fn alloc, - cm_dealloc_fn dealloc); +void cm_init(struct cheesemap* map, cm_usize key_size, cm_usize key_align, + cm_usize value_size, cm_usize value_align, cm_u8* user, + cm_hash_fn hash, cm_compare_fn compare, cm_alloc_fn alloc, + cm_dealloc_fn dealloc); void cm_drop(struct cheesemap* map); bool cm_insert(struct cheesemap* map, const cm_u8* key, const cm_u8* value); bool cm_lookup(const struct cheesemap* map, const cm_u8* key, @@ -176,9 +176,9 @@ bool cm_reserve(struct cheesemap* map, cm_usize additional); // cheesemap convenience macros // -#define cm_new_(map, K, V, user, hash_fn, cmp_fn, alloc_fn, dealloc_fn) \ - cm_new(map, sizeof(K), _Alignof(K), sizeof(V), _Alignof(V), user, hash_fn, \ - cmp_fn, alloc_fn, dealloc_fn) +#define cm_init_(map, K, V, user, hash_fn, cmp_fn, alloc_fn, dealloc_fn) \ + cm_init(map, sizeof(K), _Alignof(K), sizeof(V), _Alignof(V), user, hash_fn, \ + cmp_fn, alloc_fn, dealloc_fn) #define cm_lookup_(map, key, out_val) \ cm_lookup(map, (const cm_u8*)&(key), (cm_u8**)(out_val)) |
