diff options
author | H. Peter Anvin <hpa@zytor.com> | 2008-05-22 13:17:51 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2008-05-22 13:17:51 -0700 |
commit | 072771e4a51c8794ce7a279da76f22bd4ba37957 (patch) | |
tree | 674c8d6da4cdd99c6e4b67ed5e9a00b9a037e908 /hashtbl.c | |
parent | bd420c70959b22a8cfb44501208aa771b540678f (diff) | |
download | nasm-072771e4a51c8794ce7a279da76f22bd4ba37957.tar.gz nasm-072771e4a51c8794ce7a279da76f22bd4ba37957.tar.bz2 nasm-072771e4a51c8794ce7a279da76f22bd4ba37957.zip |
Use hash tables even for context-sensitive macros
Normally, contexts aren't used with a large number of macros, but in
case someone does, do use hash tables for those as well. This
simplifies the code somewhat, since *all* handling of macros is now
done via hash tables.
Future note: consider if it wouldn't be better to allow struct
hash_table to be allocated by the caller, instead of being allocated
by the hash table routine.
Diffstat (limited to 'hashtbl.c')
-rw-r--r-- | hashtbl.c | 9 |
1 files changed, 4 insertions, 5 deletions
@@ -11,7 +11,6 @@ #include "nasm.h" #include "hashtbl.h" -#define HASH_INITIAL_SIZE 64 #define HASH_MAX_LOAD 2 /* Higher = more memory-efficient, slower */ static struct hash_tbl_node *alloc_table(size_t newsize) @@ -22,14 +21,14 @@ static struct hash_tbl_node *alloc_table(size_t newsize) return newtbl; } -struct hash_table *hash_init(void) +struct hash_table *hash_init(size_t size) { struct hash_table *head = nasm_malloc(sizeof(struct hash_table)); - head->table = alloc_table(HASH_INITIAL_SIZE); + head->table = alloc_table(size); head->load = 0; - head->size = HASH_INITIAL_SIZE; - head->max_load = HASH_INITIAL_SIZE*(HASH_MAX_LOAD-1)/HASH_MAX_LOAD; + head->size = size; + head->max_load = size*(HASH_MAX_LOAD-1)/HASH_MAX_LOAD; return head; } |