Use the new hash table function library to store labels
[nasm.git] / hashtbl.h
blobcc3daff90b3d967584e12b847e370dff2ee60077
1 /*
2 * hashtbl.h
4 * Efficient dictionary hash table class.
5 */
7 #ifndef NASM_HASHTBL_H
8 #define NASM_HASHTBL_H
10 #include <inttypes.h>
11 #include <stddef.h>
12 #include "nasmlib.h"
14 struct hash_tbl_node {
15 uint64_t hash;
16 const char *key;
17 void *data;
20 struct hash_table {
21 struct hash_tbl_node *table;
22 size_t load;
23 size_t size;
24 size_t max_load;
27 struct hash_insert {
28 uint64_t hash;
29 struct hash_table *head;
30 struct hash_tbl_node *where;
33 uint64_t crc64(const char *string);
34 struct hash_table *hash_init(void);
35 void *hash_find(struct hash_table *head, const char *string,
36 struct hash_insert *insert);
37 void hash_add(struct hash_insert *insert, const char *string, void *data);
38 void hash_free(struct hash_table *head, void (*free_func)(char *, void *));
40 #endif /* NASM_HASHTBL_H */