aboutsummaryrefslogtreecommitdiff
path: root/list.c
diff options
context:
space:
mode:
Diffstat (limited to 'list.c')
-rw-r--r--list.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/list.c b/list.c
index 18465b0..da0c702 100644
--- a/list.c
+++ b/list.c
@@ -32,6 +32,22 @@ list_add(struct list_item *next, T data)
32 return new_item; 32 return new_item;
33} 33}
34 34
35void
36list_insert_next(struct list_item *list, T data)
37{
38 struct list_item *new_item;
39
40 new_item = malloc(sizeof *new_item);
41 if ( new_item != NULL ) {
42 new_item->data = data;
43
44 new_item->next = list->next;
45 list->next = new_item;
46 }
47 else
48 ERROR("out of memory");
49}
50
35struct list_item * 51struct list_item *
36list_delete(struct list_item *list, T data) 52list_delete(struct list_item *list, T data)
37{ 53{
@@ -56,6 +72,18 @@ list_delete(struct list_item *list, T data)
56 return list; 72 return list;
57} 73}
58 74
75void
76list_delete_next(struct list_item *list)
77{
78 if ( list->next != NULL ) {
79 struct list_item *temp = list->next;
80
81 list->next = list->next->next;
82
83 free(temp);
84 }
85}
86
59size_t 87size_t
60list_length(struct list_item *list) 88list_length(struct list_item *list)
61{ 89{