-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils2.c
67 lines (59 loc) · 1.47 KB
/
utils2.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
61
62
63
64
65
66
67
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* utils2.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: fvon-nag <fvon-nag@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/08 10:51:02 by fvon-nag #+# #+# */
/* Updated: 2023/03/09 08:20:46 by fvon-nag ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
int checkifsort(t_stacks *s)
{
int i;
if (s->as == s->max && s->as == 1)
return (1);
i = 1;
while (i < s->max)
{
if (s->a[i] <= s->a[i -1])
return (0);
i++;
}
return (1);
}
void checkforemptyarg(int argc, char **argv)
{
int i;
i = 1;
while (i < argc)
{
if (ft_strlen(argv[i]) == 0)
{
ft_printf("Error\n");
exit(0);
}
i++;
}
}
void closeerror2(t_stacks *s, char **argv)
{
free(s->a);
free(s->b);
freeout(argv);
exit(0);
}
void freeout(char **out)
{
int i;
i = 0;
while (out[i] != 0)
{
free(out[i]);
i++;
}
free(out[i]);
free(out);
}