-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstack.c
More file actions
47 lines (43 loc) · 1.52 KB
/
stack.c
File metadata and controls
47 lines (43 loc) · 1.52 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* stack.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mmoumni <mmoumni@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/12/20 12:09:53 by mmoumni #+# #+# */
/* Updated: 2022/01/05 22:19:49 by mmoumni ### ########.fr */
/* */
/* ************************************************************************** */
#include "fdf.h"
void stack_add_front(t_stack **stack, t_stack *new)
{
if (stack && new)
{
if (!(*stack))
*stack = new;
else
{
new->next = *stack;
*stack = new;
}
}
}
int fill_stack(char **sec_split, t_stack **stack)
{
t_stack *new_stack;
new_stack = (t_stack *)malloc(sizeof(t_stack));
if (!new_stack)
return (1);
new_stack->z = (t_z *)malloc(sizeof(t_z));
if (!(new_stack->z))
return (1);
new_stack->z->altitude = ft_atoi(sec_split[0]);
if (sec_split[1] != NULL)
new_stack->z->color = ft_atoi_hex(sec_split[1]);
else
new_stack->z->color = -1;
new_stack->next = NULL;
stack_add_front(stack, new_stack);
return (0);
}