-
Notifications
You must be signed in to change notification settings - Fork 0
/
free.c
60 lines (55 loc) · 1.42 KB
/
free.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* free.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: aapenko <aapenko@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/10/15 17:06:03 by aapenko #+# #+# */
/* Updated: 2023/10/15 17:07:04 by aapenko ### ########.fr */
/* */
/* ************************************************************************** */
#include "hotrace.h"
void free_buf(char **buf)
{
if (*buf)
free(*buf);
*buf = NULL;
}
void free_content(t_list *node)
{
if (node->key)
{
free(node->key);
node->key = NULL;
}
if (node->value)
{
free(node->value);
node->value = NULL;
}
}
void free_all(t_list **dict)
{
int i;
t_list *temp;
t_list *current;
i = 0;
while (i < ARRAY_SIZE)
{
if (dict[i])
{
temp = dict[i];
while (temp)
{
current = temp;
free_content(temp);
temp = temp->next;
free(current);
current = NULL;
}
}
i++;
}
free(dict);
}