diff options
Diffstat (limited to 'libcnary/node_list.c')
| -rw-r--r-- | libcnary/node_list.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/libcnary/node_list.c b/libcnary/node_list.c index dd143bb..a45457d 100644 --- a/libcnary/node_list.c +++ b/libcnary/node_list.c | |||
| @@ -25,14 +25,11 @@ | |||
| 25 | #include <stdlib.h> | 25 | #include <stdlib.h> |
| 26 | #include <string.h> | 26 | #include <string.h> |
| 27 | 27 | ||
| 28 | #include "list.h" | ||
| 29 | #include "node.h" | 28 | #include "node.h" |
| 30 | #include "node_list.h" | 29 | #include "node_list.h" |
| 31 | 30 | ||
| 32 | void node_list_destroy(node_list_t* list) { | 31 | void node_list_destroy(node_list_t* list) { |
| 33 | if(list != NULL) { | 32 | free(list); |
| 34 | list_destroy((list_t*) list); | ||
| 35 | } | ||
| 36 | } | 33 | } |
| 37 | 34 | ||
| 38 | node_list_t* node_list_create() { | 35 | node_list_t* node_list_create() { |
| @@ -43,7 +40,8 @@ node_list_t* node_list_create() { | |||
| 43 | memset(list, '\0', sizeof(node_list_t)); | 40 | memset(list, '\0', sizeof(node_list_t)); |
| 44 | 41 | ||
| 45 | // Initialize structure | 42 | // Initialize structure |
| 46 | list_init((list_t*) list); | 43 | list->begin = NULL; |
| 44 | list->end = NULL; | ||
| 47 | list->count = 0; | 45 | list->count = 0; |
| 48 | return list; | 46 | return list; |
| 49 | } | 47 | } |
| @@ -62,6 +60,9 @@ int node_list_add(node_list_t* list, node_t* node) { | |||
| 62 | if (last) { | 60 | if (last) { |
| 63 | // but only if the node list is not empty | 61 | // but only if the node list is not empty |
| 64 | last->next = node; | 62 | last->next = node; |
| 63 | } else { | ||
| 64 | // otherwise this is the start of the list | ||
| 65 | list->begin = node; | ||
| 65 | } | 66 | } |
| 66 | 67 | ||
| 67 | // Set the lists prev to the new last element | 68 | // Set the lists prev to the new last element |
