-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_free.c
48 lines (41 loc) · 1.39 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_free.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lfrank <lfrank@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/13 16:40:24 by lfrank #+# #+# */
/* Updated: 2023/03/13 16:42:29 by lfrank ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
void ft_free_ab(t_node *first_node_a, t_node *first_node_b)
{
ft_free(first_node_a);
ft_free(first_node_b);
}
void ft_free(t_node *first_node)
{
t_node *tmp;
if (first_node == NULL)
return ;
while (first_node)
{
tmp = first_node;
first_node = first_node->next;
free(tmp);
}
}
/* the last position of strarray[i] is NULL, so it'll get out of the loop */
void ft_free_strarray(char **strarray)
{
int i;
i = 0;
while (strarray[i])
{
free(strarray[i]);
i++;
}
free(strarray);
}