-
Notifications
You must be signed in to change notification settings - Fork 1
/
error_handling.c
52 lines (46 loc) · 1.36 KB
/
error_handling.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* error_handling.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lburkins <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/16 11:02:37 by lburkins #+# #+# */
/* Updated: 2024/03/04 14:06:38 by lburkins ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
void error_n_exit(char **arguments, int split_flag)
{
if (split_flag)
free_split(arguments);
write(2, "Error\n", 6);
exit (1);
}
void free_split(char **array)
{
int i;
i = 0;
while (array[i])
{
free(array[i]);
i++;
}
free(array);
}
void free_stack(t_node **stack)
{
t_node *current;
t_node *next;
if (!stack)
return ;
current = *stack;
next = NULL;
while (current)
{
next = current->next;
free(current);
current = next;
}
*stack = NULL;
}