Repository navigation
Expand file tree
/
Copy pathutils2.c
More file actions
56 lines (49 loc) · 1.4 KB
/
Copy pathutils2.c
File metadata and controls
56 lines (49 loc) · 1.4 KB
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* utils2.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: asalniko <asalniko@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/08/12 22:09:24 by asalniko #+# #+# */
/* Updated: 2025/08/13 20:56:12 by asalniko ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
int nb_abs(int nb)
{
if (nb < 0)
return (-nb);
return (nb);
}
void ft_putstr(char *str)
{
int i;
i = 0;
while (str[i])
{
write(1, &str[i], 1);
i++;
}
}
void free_stack(t_stack **stack)
{
t_stack *tmp;
if (!stack)
return ;
while (*stack)
{
tmp = (*stack)->next;
free(*stack);
*stack = tmp;
}
}
void exit_error(t_stack **stack_a, t_stack **stack_b)
{
if (stack_a && *stack_a)
free_stack(stack_a);
if (stack_b && *stack_b)
free_stack(stack_b);
write(2, "Error\n", 6);
exit(1);
}