data_structures
hashset_delete.c
Go to the documentation of this file.
1 /* ************************************************************************** */
3 /* */
4 /* ::: :::::::: */
5 /* hashset_delete.c :+: :+: :+: */
6 /* +:+ +:+ +:+ */
7 /* By: unite <marvin@42.fr> +#+ +:+ +#+ */
8 /* +#+#+#+#+#+ +#+ */
9 /* Created: 2020/07/21 19:04:25 by unite #+# #+# */
10 /* Updated: 2020/09/03 22:29:58 by unite ### ########.fr */
11 /* */
12 /* ************************************************************************** */
13 
14 #include "hashset.h"
15 
17 {
18  size_t i;
19 
20  if (!hs)
21  return ;
22  if (hs->vals)
23  {
24  i = 0;
25  while (i < hs->capacity)
26  hs->type->del(hs->vals[i++]);
27  free(hs->vals);
28  }
29  free(hs);
30 }
hashset.h
s_hashset::vals
void ** vals
The data.
Definition: hashset.h:45
hashset_delete
void hashset_delete(t_hashset *hs)
Deletes this hashset and frees all its items and the associated data.
Definition: hashset_delete.c:16
s_type::del
void(* del)(void *)
A function pointer used to free the memory taken by the data type.
Definition: types.h:51
s_hashset
A dynamically resizing linear-probing hashset.
Definition: hashset.h:43
s_hashset::type
const t_type * type
The type of elements in the hashset.
Definition: hashset.h:48