-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_stack.c
More file actions
39 lines (36 loc) · 1.42 KB
/
Copy pathbuild_stack.c
File metadata and controls
39 lines (36 loc) · 1.42 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* build_stack.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: atok <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/06 21:04:34 by atok #+# #+# */
/* Updated: 2023/03/07 17:19:58 by atok ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
void ft_add_nodes_to_stack_a(t_stack *stack, int num)
{
t_node *new_node;
t_node *current_node;
new_node = (t_node *) malloc (sizeof(t_node));
new_node->index = -42;
new_node->data = num;
new_node->next = NULL;
if (stack->stack_a == NULL)
{
new_node->prev = NULL;
stack->stack_a = new_node;
stack->counter_a++;
}
else
{
current_node = stack->stack_a;
while (current_node->next != NULL)
current_node = current_node->next;
current_node->next = new_node;
new_node->prev = current_node;
stack->counter_a++;
}
}