-
Notifications
You must be signed in to change notification settings - Fork 0
/
parsing2_bonus.c
59 lines (54 loc) · 1.51 KB
/
parsing2_bonus.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* parsing2_bonus.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: abazerou <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/05/30 14:39:44 by abazerou #+# #+# */
/* Updated: 2023/06/06 17:34:21 by abazerou ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
int *arr_cpy_init_bonus(t_v *v)
{
v->arr_cpy = malloc(sizeof(int) * (v->size));
if (!v->arr_cpy)
{
free(v->arr_cpy);
return (NULL);
}
while (v->s[v->i])
{
v->arr_cpy[v->i] = v->arr[v->i];
v->i++;
}
return (v->arr_cpy);
}
int *arr_init_bonus(t_v *v)
{
v->arr = malloc(sizeof(int) * (v->size));
if (!v->arr)
{
free(v->arr);
return (NULL);
}
while (v->s[v->i])
{
v->arr[v->i] = check_num_bonus(v->s[v->i]);
v->i++;
}
v->i = 0;
return (v->arr);
}
void ft_free_stack_bonus(t_list **stack)
{
t_list *tmp;
tmp = *(stack);
while (tmp)
{
(*stack) = (*stack)->next;
free(tmp);
tmp = tmp->next;
}
}