summaryrefslogtreecommitdiffstats
path: root/libcnary/node_list.c
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2019-01-21 05:11:03 +0100
committerGravatar Nikias Bassen2019-01-21 05:11:03 +0100
commitbec850fe399639f3b8582a39386216970dea15ed (patch)
tree702ab16623adcdd186483d70006a772ffe97a637 /libcnary/node_list.c
parentafec7339b830461042e5af9cb9561563cf3ba28d (diff)
downloadlibplist-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.c11
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 @@
#include <stdlib.h>
#include <string.h>
-#include "list.h"
#include "node.h"
#include "node_list.h"
void node_list_destroy(node_list_t* list) {
- if(list != NULL) {
- list_destroy((list_t*) list);
- }
+ free(list);
}
node_list_t* node_list_create() {
@@ -43,7 +40,8 @@ node_list_t* node_list_create() {
memset(list, '\0', sizeof(node_list_t));
// Initialize structure
- list_init((list_t*) list);
+ list->begin = NULL;
+ list->end = NULL;
list->count = 0;
return list;
}
@@ -62,6 +60,9 @@ int node_list_add(node_list_t* list, node_t* node) {
if (last) {
// but only if the node list is not empty
last->next = node;
+ } else {
+ // otherwise this is the start of the list
+ list->begin = node;
}
// Set the lists prev to the new last element