Skip to content

Commit

Permalink
>>> del ht
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin4477 committed Nov 4, 2023
1 parent 81c5197 commit a01e229
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions 0x1A-hash_tables/6-hash_table_delete.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include "hash_tables.h"

/**
* hash_table_delete - deletes a hash table.
* @ht: the hash table.
*/
void hash_table_delete(hash_table_t *ht)
{
unsigned long int i = 0;
hash_node_t *node;

while (i < ht->size)
{
while (ht->array[i] != NULL)
{
node = ht->array[i]->next;
free(ht->array[i]->key);
free(ht->array[i]->value);
free(ht->array[i]);
ht->array[i] = node;
}
i++;
}
free(ht->array);
free(ht);
}

0 comments on commit a01e229

Please sign in to comment.