-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclear_and_free.c
65 lines (57 loc) · 1.63 KB
/
clear_and_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
61
62
63
64
65
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* clear_and_free.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: natamazy <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/22 15:01:32 by natamazy #+# #+# */
/* Updated: 2024/02/22 17:09:04 by natamazy ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
void free_split_and_stack(char **numbers, t_stack *a_sf)
{
int j;
j = 0;
while (numbers[j] != NULL)
free(numbers[j++]);
free(numbers);
while (a_sf->start->next)
ft_lstclear(&a_sf->start->next);
free(a_sf);
}
void free_stack(t_stack *a_sf, t_stack *b_sf, t_list *node)
{
while (a_sf->start)
ft_lstclear(&a_sf->start);
free(a_sf);
free(b_sf);
free(node);
a_sf = NULL;
b_sf = NULL;
node = NULL;
}
void free_split(char **numbers)
{
int j;
j = 0;
while (numbers[j] != NULL)
{
free(numbers[j]);
j++;
}
free(numbers);
}
void free_sf(t_stack *sf)
{
sf->start = NULL;
sf->finish = NULL;
sf = NULL;
}
void go_to_next(t_stack *sf, t_list *node)
{
sf->finish = sf->start;
sf->start = node->next;
node->next->prev = NULL;
}