diff options
| author | Thomas Schmucker <ts@its1.de> | 2020-09-02 15:08:39 +0200 |
|---|---|---|
| committer | Thomas Schmucker <ts@its1.de> | 2020-09-02 15:08:39 +0200 |
| commit | 234d9500e3e2462a5404d5e675fa5a7b8038d059 (patch) | |
| tree | dd4c9c81676fe3aeba26a9e9c09dba755681e3ec | |
| parent | 4b3ab034720dc4d5afda8db866de96caf2aa1c29 (diff) | |
| download | data-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.c | 8 |
1 files changed, 3 insertions, 5 deletions
| @@ -33,17 +33,16 @@ list_add(struct list_item *next, T data) | |||
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | void | 35 | void |
| 36 | list_insert_next(struct list_item *node, T data) | 36 | list_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) | |||
| 76 | void | 75 | void |
| 77 | list_delete_next(struct list_item *list) | 76 | list_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 | ||
