diff options
author | Preston Pan <preston@nullring.xyz> | 2023-01-03 00:27:06 -0800 |
---|---|---|
committer | Preston Pan <preston@nullring.xyz> | 2023-01-03 00:27:06 -0800 |
commit | 9f342255a2260480701cc2ac2d0c623d4aba1348 (patch) | |
tree | 6ecd1332032eb09fd28aacab7418da9a5882cb94 /src/hash_table.c | |
parent | 64feef1b9ea72adf7ba32998e9dca7d507607498 (diff) |
add some comments; fix some bugs in advance
Diffstat (limited to 'src/hash_table.c')
-rw-r--r-- | src/hash_table.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/hash_table.c b/src/hash_table.c index 9384945..3ca6dd0 100644 --- a/src/hash_table.c +++ b/src/hash_table.c @@ -70,6 +70,12 @@ ast_t *sl_list_get(sl_list_t *l, char *key) { return NULL; } +bool sl_list_exists(sl_list_l, char *key) { + if (sl_list_get(l, key) != NULL) + return true; + return false; +} + void sl_list_free(sl_list_t *l) { sl_node_t *cur = l->head; sl_node_t *tmp; @@ -111,6 +117,11 @@ void hash_table_free(hash_table_t *h) { free(h); } +bool hash_table_exists(hash_table_t *h, char *key) { + sl_list_t *l = h->buckets[hash(key, h->size)]; + return sl_list_exists(l, key); +} + /* DJB2 HASH FUNCTION */ unsigned long hash(char *key, int size) { unsigned long hash = 5381; |