-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpush.c
More file actions
49 lines (44 loc) · 1.4 KB
/
Copy pathpush.c
File metadata and controls
49 lines (44 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* push.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: isel-azz <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/11 07:48:50 by isel-azz #+# #+# */
/* Updated: 2024/05/11 07:49:00 by isel-azz ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
void push(t_stack_needs **dest, t_stack_needs **src)
{
t_stack_needs *node;
if (*src == NULL)
return ;
node = *src;
*src = (*src)->next;
if (*src)
(*src)->prev = NULL;
node->prev = NULL;
if (*dest == NULL)
{
*dest = node;
node->next = NULL;
}
else
{
node->next = *dest;
node->next->prev = node;
*dest = node;
}
}
void push_a(t_stack_needs **a, t_stack_needs **b)
{
push(a, b);
write(1, "pa\n", 3);
}
void push_b(t_stack_needs **a, t_stack_needs **b)
{
push(b, a);
write(1, "pb\n", 3);
}