aboutsummaryrefslogtreecommitdiffstats
path: root/README.md
diff options
context:
space:
mode:
authorFabrice <fabrice@schaub-dev.xyz>2026-03-24 09:19:41 +0100
committerFabrice <fabrice@schaub-dev.xyz>2026-03-24 09:19:41 +0100
commit5cb7df67220e6d34c2456e3e51a839df9acb87b0 (patch)
treeaa08d00ca181c1ea27092ba543f6a1223e2a1bfc /README.md
parentdb8d25f96f137c2ba170ea3caa9c2ad6a3dce40e (diff)
allocator configuration
Diffstat (limited to 'README.md')
-rw-r--r--README.md15
1 files changed, 14 insertions, 1 deletions
diff --git a/README.md b/README.md
index 17df1cf..759b7d0 100644
--- a/README.md
+++ b/README.md
@@ -45,10 +45,23 @@ bool compare_string(const uint8_t* key1, const uint8_t* key2, uint8_t* user) {
return strcmp(*(const char**)key1, *(const char**)key2) == 0;
}
+// Default allocator (uses malloc)
+void* default_alloc(uintptr_t size, uint8_t* user) {
+ (void)user;
+ return malloc(size);
+}
+
+// Default deallocator (uses free)
+void default_dealloc(void* ptr, uint8_t* user) {
+ (void)user;
+ free(ptr);
+}
+
int main(void) {
// Create a map: string -> int (word frequency counter)
struct cheesemap map;
- cm_new_(&map, const char*, int, NULL, hash_string, compare_string);
+ cm_new_(&map, const char*, int, NULL, hash_string, compare_string,
+ default_alloc, default_dealloc);
// Count word frequencies
const char* words[] = {"hello", "world", "hello",