From d3eacfad5e3afca053d7bf17b0f6c1c14a2d2ae5 Mon Sep 17 00:00:00 2001 From: mbr Date: Fri, 1 Sep 2017 23:08:16 +0200 Subject: [PATCH] Corrected deletion of items --- 05-methods/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/05-methods/README.md b/05-methods/README.md index fc74c08..9a64e5c 100644 --- a/05-methods/README.md +++ b/05-methods/README.md @@ -84,13 +84,14 @@ void ht_delete(ht_hash_table* ht, const char* key) { if (strcmp(item->key, key) == 0) { ht_del_item(item); ht->items[index] = &HT_DELETED_ITEM; + ht->count--; + return; } } index = ht_get_hash(key, ht->size, i); item = ht->items[index]; i++; } - ht->count--; } ``` After deleting, we decrement the hash table's `count` attribute.