-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_rr.c
More file actions
59 lines (54 loc) · 1.71 KB
/
ft_rr.c
File metadata and controls
59 lines (54 loc) · 1.71 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
50
51
52
53
54
55
56
57
58
59
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_rr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: slepetit <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/21 23:12:37 by slepetit #+# #+# */
/* Updated: 2022/09/06 20:36:08 by slepetit ### ########.fr */
/* */
/* ************************************************************************** */
#include "pushswap.h"
void ft_ra(t_stack **lst)
{
t_stack *tmp;
if (!(*lst))
return ;
if ((*lst)->next == NULL)
return ;
tmp = (*lst);
while (tmp->next != NULL)
tmp = tmp->next;
tmp->next = malloc(sizeof(t_stack));
tmp->next->next = NULL;
tmp->next->prev = (tmp);
tmp->next->data = (*lst)->data;
tmp->next->pos = (*lst)->pos;
tmp = (*lst);
(*lst) = (*lst)->next;
(*lst)->prev = NULL;
free(tmp);
write(1, "ra\n", 3);
}
void ft_rb(t_stack **lst)
{
t_stack *tmp;
if (!(*lst))
return ;
if ((*lst)->next == NULL)
return ;
tmp = (*lst);
while (tmp->next != NULL)
tmp = tmp->next;
tmp->next = malloc(sizeof(t_stack));
tmp->next->next = NULL;
tmp->next->prev = (tmp);
tmp->next->data = (*lst)->data;
tmp->next->pos = (*lst)->pos;
tmp = (*lst);
(*lst) = (*lst)->next;
(*lst)->prev = NULL;
free(tmp);
write(1, "rb\n", 3);
}