diff options
Diffstat (limited to 'util/dict.h')
| -rw-r--r-- | util/dict.h | 11 |
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); |
