Skip to content

Commit

Permalink
Fix hashtable del bug
Browse files Browse the repository at this point in the history
  • Loading branch information
git-hulk committed Nov 22, 2018
1 parent ebdcfdf commit 09dfdde
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/hashtable.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,10 @@ int hashtable_del(hashtable *ht, char *key) {
current_key_size = strlen(current->key);
if (key_size == current_key_size
&& !strncmp(key, current->key, key_size)) {
prev->next = current->next;
if (current == ht->buckets[bucket]) {
ht->buckets[bucket] = NULL;
ht->buckets[bucket] = current->next;
} else {
prev->next = current->next;
}
free(current->key);
ht->free ? ht->free(current->value):free(current->value);
Expand Down

0 comments on commit 09dfdde

Please sign in to comment.