Projects/1BIT/summer-semester/IJC-2/htab_clear.c
2026-04-14 19:28:46 +02:00

22 lines
No EOL
541 B
C

// htab_clear.c
// Řešení IJC-DU2, příklad b), 22.4.2024
// Autor: Roman Nečas, FIT
// Přeloženo: gcc 11.4.0
#include <stdlib.h>
#include "htab.h"
#include "htab_struct.h"
void htab_clear(htab_t *t) {
for (size_t i = 0; i < t->arr_size; i++) {
struct htab_item *item = t->arr_ptr[i];
while (item != NULL) {
struct htab_item *next = item->next;
free((void *)item->pair.key);
free(item);
item = next;
}
t->arr_ptr[i] = NULL;
}
t->size = 0;
}