-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherror_handling.c
60 lines (53 loc) · 1.44 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
53
54
55
56
57
58
59
60
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* error_handling.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: zhlim <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/28 17:38:26 by zhlim #+# #+# */
/* Updated: 2023/08/05 18:19:07 by zhlim ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
void free_args(char **args)
{
int i;
i = 0;
if (!args)
return ;
while (args[i])
{
free(args[i]);
i++;
}
free(args);
}
void write_error(char *str)
{
if (!str)
return ;
write(2, str, ft_strlen(str));
}
void print_error_exit(char *str)
{
if (!str)
return ;
write_error(str);
exit(1);
}
void free_error_exit(char *str, t_list *stack)
{
if (!stack)
return ;
write_error(str);
ft_lstclear(&stack, destroy_content);
exit(1);
}
void free_exit(t_list *stack)
{
if (!stack)
return ;
ft_lstclear(&stack, destroy_content);
exit(1);
}