aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Schmucker <ts@its1.de>2020-09-02 15:08:39 +0200
committerThomas Schmucker <ts@its1.de>2020-09-02 15:08:39 +0200
commit234d9500e3e2462a5404d5e675fa5a7b8038d059 (patch)
treedd4c9c81676fe3aeba26a9e9c09dba755681e3ec
parent4b3ab034720dc4d5afda8db866de96caf2aa1c29 (diff)
downloaddata-structures-234d9500e3e2462a5404d5e675fa5a7b8038d059.tar.gz
data-structures-234d9500e3e2462a5404d5e675fa5a7b8038d059.tar.bz2
data-structures-234d9500e3e2462a5404d5e675fa5a7b8038d059.zip
Feature: Der Code zum Einfügen und zum Löschen des nächsten Listenelements sollte so passen!
-rw-r--r--list.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/list.c b/list.c
index fb21779..da0c702 100644
--- a/list.c
+++ b/list.c
@@ -33,17 +33,16 @@ list_add(struct list_item *next, T data)
33} 33}
34 34
35void 35void
36list_insert_next(struct list_item *node, T data) 36list_insert_next(struct list_item *list, T data)
37{ 37{
38 struct list_item *new_item; 38 struct list_item *new_item;
39 39
40 // TODO: Debuggen und nochmal richtig drüber nachdenken!
41 new_item = malloc(sizeof *new_item); 40 new_item = malloc(sizeof *new_item);
42 if ( new_item != NULL ) { 41 if ( new_item != NULL ) {
43 new_item->next = node->next;
44 new_item->data = data; 42 new_item->data = data;
45 43
46 node->next = new_item; 44 new_item->next = list->next;
45 list->next = new_item;
47 } 46 }
48 else 47 else
49 ERROR("out of memory"); 48 ERROR("out of memory");
@@ -76,7 +75,6 @@ list_delete(struct list_item *list, T data)
76void 75void
77list_delete_next(struct list_item *list) 76list_delete_next(struct list_item *list)
78{ 77{
79 // TODO: Debuggen und nochmal richtig drüber nachdenken!
80 if ( list->next != NULL ) { 78 if ( list->next != NULL ) {
81 struct list_item *temp = list->next; 79 struct list_item *temp = list->next;
82 80