// htab_init // Řešení IJC-DU2, příklad b), 22.4.2024 // Autor: Roman Nečas, FIT // Přeloženo: gcc 11.4.0 #include #include "htab.h" #include "htab_struct.h" htab_t *htab_init(const size_t n) { htab_t *t = malloc(sizeof(htab_t) + n * sizeof(struct htab_item *)); if (t == NULL) return NULL; t->size = 0; t->arr_size = n; t->arr_ptr = (struct htab_item **)((char *)t + sizeof(htab_t)); for (size_t i = 0; i < n; i++) t->arr_ptr[i] = NULL; return t; }