diff --git a/clib.json b/clib.json index 206c9e0..5376304 100644 --- a/clib.json +++ b/clib.json @@ -1,6 +1,6 @@ { "name": "libhash", - "version": "1.0.0", + "version": "1.1.0", "author": "Matthew Zito", "repo": "exbotanical/libhash", "license": "MIT", diff --git a/src/hash_table.c b/src/hash_table.c index 55fe190..f027dd8 100644 --- a/src/hash_table.c +++ b/src/hash_table.c @@ -44,15 +44,15 @@ static void ht_resize(hash_table *ht, int base_capacity) { const int tmp_capacity = ht->capacity; ht->capacity = new_ht->capacity; - new_ht->capacity = tmp_capacity; + // Cannot free values - we may still be using them. ht_entry **tmp_entries = ht->entries; ht->entries = new_ht->entries; - new_ht->entries = tmp_entries; + free(tmp_entries); + + list_free(ht->occupied_buckets); ht->occupied_buckets = new_ht->occupied_buckets; - // Cannot free values - we may still be using them. - free(new_ht->entries); free(new_ht); } @@ -183,6 +183,7 @@ static void __ht_delete_table(hash_table *ht) { } } + // list_free(ht->occupied_buckets); free(ht->entries); free(ht); } diff --git a/src/list.h b/src/list.h index 139ea06..7c51db3 100644 --- a/src/list.h +++ b/src/list.h @@ -50,9 +50,9 @@ static void list_remove(node_t **head, int value) { } // TODO: Use and test -static void free_list(node_t *head) { +static void list_free(node_t *head) { node_t *tmp; - while (head) { + while (head != &LIST_SENTINEL_NODE) { tmp = head; head = head->next; free(tmp);