aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--list.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/list.c b/list.c
index 18465b0..fb21779 100644
--- a/list.c
+++ b/list.c
@@ -32,6 +32,23 @@ 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 *node, T data)
37{
38 struct list_item *new_item;
39
40 // TODO: Debuggen und nochmal richtig drüber nachdenken!
41 new_item = malloc(sizeof *new_item);
42 if ( new_item != NULL ) {
43 new_item->next = node->next;
44 new_item->data = data;
45
46 node->next = new_item;
47 }
48 else
49 ERROR("out of memory");
50}
51
35struct list_item * 52struct list_item *
36list_delete(struct list_item *list, T data) 53list_delete(struct list_item *list, T data)
37{ 54{
@@ -56,6 +73,19 @@ list_delete(struct list_item *list, T data)
56 return list; 73 return list;
57} 74}
58 75
76void
77list_delete_next(struct list_item *list)
78{
79 // TODO: Debuggen und nochmal richtig drüber nachdenken!
80 if ( list->next != NULL ) {
81 struct list_item *temp = list->next;
82
83 list->next = list->next->next;
84
85 free(temp);
86 }
87}
88
59size_t 89size_t
60list_length(struct list_item *list) 90list_length(struct list_item *list)
61{ 91{