aboutsummaryrefslogtreecommitdiff
path: root/src/stem.c
diff options
context:
space:
mode:
authorPreston Pan <preston@nullring.xyz>2024-01-26 13:55:33 -0800
committerPreston Pan <preston@nullring.xyz>2024-01-26 13:55:33 -0800
commit20bd9521cd558e39eca4aac5f3db8e390f49ba2d (patch)
treeec7d99825c003ff5e06f224cd3c4009a5dde6d20 /src/stem.c
parent2750e54a2ad5afeabb7093fc10e9fb686b6f6059 (diff)
Change README
Diffstat (limited to 'src/stem.c')
-rw-r--r--src/stem.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/stem.c b/src/stem.c
index f5a13ad..f623ae7 100644
--- a/src/stem.c
+++ b/src/stem.c
@@ -447,16 +447,22 @@ ht_t *init_ht(size_t size) {
}
void ht_add(ht_t *h, string_t *key, void *v, void (*freefunc)(void *)) {
+ if (key == NULL)
+ return;
sll_add(h->buckets[hash(h, key->value)], key, v, freefunc);
}
void *ht_get(ht_t *h, string_t *key) {
+ if (key == NULL)
+ return NULL;
return sll_get(h->buckets[hash(h, key->value)], key);
}
bool ht_exists(ht_t *h, string_t *key) { return ht_get(h, key) != NULL; }
void ht_delete(ht_t *h, string_t *key, void (*freefunc)(void *)) {
+ if (key == NULL)
+ return;
sll_delete(h->buckets[hash(h, key->value)], key, freefunc);
}