-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils2.c
More file actions
44 lines (38 loc) · 1.24 KB
/
utils2.c
File metadata and controls
44 lines (38 loc) · 1.24 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: bschwitz <marvin@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/04/05 17:08:28 by bschwitz #+# #+# */
/* Updated: 2022/04/11 16:23:31 by bschwitz ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
void ft_error(char *msg)
{
ft_putendl_fd(msg, 1);
exit(0);
}
void ft_free(char **str)
{
int i;
i = 0;
while (str[i])
i++;
while (i > 0)
free(str[i--]);
}
int is_sorted(t_stack **stack)
{
t_stack *head;
head = *stack;
while (head && head->next)
{
if (head->value > head->next->value)
return (0);
head = head->next;
}
return (1);
}