diff options
author | H. Peter Anvin (Intel) <hpa@zytor.com> | 2018-12-11 12:30:25 -0800 |
---|---|---|
committer | H. Peter Anvin (Intel) <hpa@zytor.com> | 2018-12-11 13:18:49 -0800 |
commit | ebb05a0e5fa8dfae58e6a00e550005df4b0f58f8 (patch) | |
tree | 337a6804dc6a86858bbd02d7e55af58e7a6c9e3f /nasmlib/strlist.c | |
parent | ddb290681e52aee70fc4b3342829fb9770a089b2 (diff) | |
download | nasm-ebb05a0e5fa8dfae58e6a00e550005df4b0f58f8.tar.gz |
hashtbl: revamp the hash table interface, support binary keys
Add binary key support to the hash table interface. Clean up the
interface to contain less extraneous crud.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Diffstat (limited to 'nasmlib/strlist.c')
-rw-r--r-- | nasmlib/strlist.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/nasmlib/strlist.c b/nasmlib/strlist.c index 868fa3bf..6dfaa46e 100644 --- a/nasmlib/strlist.c +++ b/nasmlib/strlist.c @@ -43,7 +43,6 @@ struct strlist *strlist_alloc(void) { struct strlist *list = nasm_zalloc(sizeof(*list)); - hash_init(&list->hash, HASH_MEDIUM); list->tailp = &list->head; return list; } @@ -56,20 +55,19 @@ bool strlist_add(struct strlist *list, const char *str) { struct strlist_entry *e; struct hash_insert hi; - size_t len; + size_t size; if (!list) return false; - if (hash_find(&list->hash, str, &hi)) + size = strlen(str) + 1; + if (hash_findb(&list->hash, str, size, &hi)) return false; - len = strlen(str); - /* Structure already has char[1] as EOS */ - e = nasm_zalloc(sizeof(*e) + len); - e->len = len; - memcpy(e->str, str, len + 1); + e = nasm_zalloc(sizeof(*e) - 1 + size); + e->size = size; + memcpy(e->str, str, size); *list->tailp = e; list->tailp = &e->next; |