-
Notifications
You must be signed in to change notification settings - Fork 1
/
stack_utilities2.c
45 lines (40 loc) · 1.28 KB
/
stack_utilities2.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* stack_utilities2.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: akaraban <akaraban@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/04/15 21:53:42 by akaraban #+# #+# */
/* Updated: 2023/04/15 23:07:18 by akaraban ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
int is_sorted(t_stack **stack)
{
t_stack *trav;
t_stack *ahead;
trav = *stack;
ahead = trav->next;
while (ahead)
{
if (trav->index > ahead->index)
return (0);
trav = ahead;
ahead = trav->next;
}
return (1);
}
void free_stack(t_stack **stack)
{
t_stack *head;
t_stack *tmp;
head = *stack;
while (head)
{
tmp = head;
head = head->next;
free(tmp);
}
free(stack);
}