-
Notifications
You must be signed in to change notification settings - Fork 0
/
delete_ft.c
93 lines (83 loc) · 1.98 KB
/
delete_ft.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* delete_ft.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rvan-der <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/19 18:00:27 by rvan-der #+# #+# */
/* Updated: 2017/02/27 16:33:25 by rvan-der ### ########.fr */
/* */
/* ************************************************************************** */
#include "filler.h"
void delete_map(char **map, int size)
{
int i;
if (map != NULL && *map != NULL)
{
i = -1;
while (++i < size)
ft_strdel(&(map[i]));
free(map);
map = NULL;
}
}
void delete_elem(int x, int y, t_coord **list)
{
t_coord *tmp;
t_coord *elem;
if ((tmp = *list) != NULL)
{
if (tmp->x == x && tmp->y == y)
{
*list = tmp->next;
free(tmp);
}
else
{
while ((elem = tmp->next) != NULL)
{
if (elem->x == x && elem->y == y)
{
tmp->next = elem->next;
free(elem);
break ;
}
tmp = tmp->next;
}
}
}
}
void delete_crdlist(t_coord **list)
{
t_coord *tmp;
t_coord *nxt;
if (list == NULL || (tmp = *list) == NULL)
return ;
while (tmp->next != NULL)
{
nxt = tmp->next;
free(tmp);
tmp = nxt;
}
*list = NULL;
}
void delete_skin(t_skin **list)
{
t_skin *tmp;
t_skin *nxt;
if (list == NULL || (tmp = *list) == NULL)
return ;
while (tmp->next != NULL)
{
nxt = tmp->next;
free(tmp);
tmp = nxt;
}
*list = NULL;
}
void delete_all(t_plateau p, t_ennemi e)
{
delete_crdlist(&(p.pos));
delete_skin(&(e.skin));
}