-
Notifications
You must be signed in to change notification settings - Fork 0
/
frees.c
49 lines (44 loc) · 1.35 KB
/
frees.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* frees.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ana-lda- <ana-lda-@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/07/05 16:12:25 by ana-lda- #+# #+# */
/* Updated: 2024/07/09 16:38:15 by ana-lda- ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
/** @brief Frees the elements generated by split funtion.*/
int free_split(int argc, char **argv, bool flag)
{
int i;
i = 0;
if (argc == 2)
{
while (argv[i] != NULL)
{
free(argv[i]);
i++;
}
free(argv);
}
if (flag)
{
write(2, "Error\n", 6);
exit(1);
}
return (0);
}
/** @brief Frees elements of stack and stack.*/
void free_stack(t_stack *node)
{
t_stack *temp;
while (node)
{
temp = node;
node = (node)->next;
free(temp);
}
}