From db1b9c8dcb0d115217a33c2fe8e0760d49143e11 Mon Sep 17 00:00:00 2001 From: kartofen Date: Sat, 13 Sep 2025 15:24:28 +0300 Subject: ast nearly build and proper errors --- util/dict.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'util/dict.h') 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); -- cgit v1.2.3