-
Notifications
You must be signed in to change notification settings - Fork 1
/
ft_free.c
54 lines (49 loc) · 1.46 KB
/
ft_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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_free.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: schaaban <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/12/07 15:54:47 by schaaban #+# #+# */
/* Updated: 2017/12/08 05:33:12 by schaaban ### ########.fr */
/* */
/* ************************************************************************** */
#include "fillit.h"
#include "libft/libft.h"
#include <stdlib.h>
static void ft_freemap(t_map ***list)
{
int i;
i = 0;
if ((*list) != NULL)
{
while ((*list)[i] != NULL)
map_dtor((*list)[i++]);
free((*list));
(*list) = NULL;
}
}
void ft_freeall(t_tetri ***list, t_map ***map_list, char ***tab)
{
int i;
i = 0;
ft_freemap(map_list);
if (*tab != NULL)
{
while ((*tab)[i] != NULL)
{
free((*tab)[i]);
(*tab)[i++] = NULL;
}
free((*tab));
}
i = 0;
if ((*list) != NULL)
{
while ((*list)[i] != NULL)
tetri_dtor((*list)[i++]);
free((*list));
(*list) = NULL;
}
}