diff options
| author | 2019-01-21 05:11:03 +0100 | |
|---|---|---|
| committer | 2019-01-21 05:11:03 +0100 | |
| commit | bec850fe399639f3b8582a39386216970dea15ed (patch) | |
| tree | 702ab16623adcdd186483d70006a772ffe97a637 /libcnary/node_list.c | |
| parent | afec7339b830461042e5af9cb9561563cf3ba28d (diff) | |
| download | libplist-bec850fe399639f3b8582a39386216970dea15ed.tar.gz libplist-bec850fe399639f3b8582a39386216970dea15ed.tar.bz2 | |
libcnary: Remove list.c/list.h and just do everything in node_list.c
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 |
