-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlist_functions.c
More file actions
68 lines (57 loc) · 1.76 KB
/
list_functions.c
File metadata and controls
68 lines (57 loc) · 1.76 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
60
61
62
63
64
65
66
67
68
/* ************************************************************************** */
/* */
/* :::::::: */
/* list_functions.c :+: :+: */
/* +:+ */
/* By: rcorke <rcorke@student.codam.nl> +#+ */
/* +#+ */
/* Created: 2019/08/15 16:41:16 by rcorke #+# #+# */
/* Updated: 2019/08/19 12:48:41 by rcorke ######## odam.nl */
/* */
/* ************************************************************************** */
#include "push_swap.h"
int get_end_list_value(t_blist *list)
{
t_blist *iter;
iter = list;
while (iter->next)
iter = iter->next;
return (iter->value);
}
void add_to_list_end(t_blist *list, int to_add)
{
t_blist *new;
t_blist *iter;
new = (t_blist *)malloc(sizeof(t_blist));
new->value = to_add;
new->next = NULL;
iter = list;
while (iter->next != NULL)
iter = iter->next;
iter->next = new;
}
void pop_list_end(t_blist *list)
{
t_blist *iter;
iter = list;
while (iter->next->next != NULL)
iter = iter->next;
free(iter->next);
iter->next = NULL;
}
void change_end_list_value(t_blist *list, int new_value)
{
t_blist *iter;
iter = list;
while (iter->next != NULL)
iter = iter->next;
iter->value = new_value;
}
t_blist *create_list(t_ps *ps)
{
t_blist *list;
list = (t_blist *)malloc(sizeof(t_blist));
list->value = ps->size;
list->next = NULL;
return (list);
}