aboutsummaryrefslogtreecommitdiff
path: root/util/dict.h
diff options
context:
space:
mode:
authorkartofen <kartofen.mail.0@protonmail.com>2025-09-13 15:24:28 +0300
committerkartofen <kartofen.mail.0@protonmail.com>2025-09-13 15:24:28 +0300
commitdb1b9c8dcb0d115217a33c2fe8e0760d49143e11 (patch)
treec93743adff3d78ea066c14879b7d2bfeb3ce42fb /util/dict.h
parent46e786db9d1b48b8fbc3502e36f093b755f3e09f (diff)
ast nearly build and proper errors
Diffstat (limited to 'util/dict.h')
-rw-r--r--util/dict.h11
1 files changed, 10 insertions, 1 deletions
diff --git a/util/dict.h b/util/dict.h
index 2da8e6f..b19e766 100644
--- a/util/dict.h
+++ b/util/dict.h
@@ -26,9 +26,18 @@ struct dict {
struct level start_level;
struct level *bit_to_ptr[MAPPED_CHARS];
size_t num_levels;
+
+ // allocator
+ void *(*calloc)(size_t, size_t);
+ void (*free)(void *);
};
-#define DICT_INIT(strings_, nstrings_, char_to_bit_) (struct dict){.strings = strings_, .nstrings = nstrings_, .char_to_bit = char_to_bit_}
+#define DICT_INIT(strings_, nstrings_, char_to_bit_) (struct dict){.strings = strings_, .nstrings = nstrings_, .char_to_bit = char_to_bit_, .calloc = NULL, .free = NULL}
+
+#define DICT_SET_ALLOCATOR(dict, calloc_, free_) do { \
+ (dict)->calloc = (calloc_); \
+ (dict)->free = (free_); \
+ } while(0)
int dict_compile(struct dict *d);
void dict_free(struct dict *d);