-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrie_clear.c
executable file
·40 lines (37 loc) · 1.3 KB
/
trie_clear.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* trie_clear.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: akharrou <akharrou@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/02/22 11:37:44 by akharrou #+# #+# */
/* Updated: 2019/03/04 13:17:20 by akharrou ### ########.fr */
/* */
/* ************************************************************************** */
#include "../Includes/stdlib_42.h"
#include "../Includes/trie.h"
int trie_clear(t_trie **root)
{
unsigned int i;
if (root && *root)
{
i = 0;
while (i < SIZE_OF_ARRAY)
{
if (((*root)->children)[i])
if ((trie_clear(&(((*root)->children)[i]))) == -1)
return (-1);
i++;
}
if ((*root)->item)
{
free((*root)->item);
(*root)->item = NULL;
}
free(*root);
(*root) = NULL;
return (0);
}
return (-1);
}