summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libcnary/Makefile.am2
-rw-r--r--libcnary/include/list.h40
-rw-r--r--libcnary/list.c47
-rw-r--r--libcnary/node_list.c11
4 files changed, 6 insertions, 94 deletions
diff --git a/libcnary/Makefile.am b/libcnary/Makefile.am
index 5a26fb5..e2187ec 100644
--- a/libcnary/Makefile.am
+++ b/libcnary/Makefile.am
@@ -6,9 +6,7 @@ libcnary_la_LIBADD =
libcnary_la_LDFLAGS = $(AM_LDFLAGS) -no-undefined
libcnary_la_SOURCES = \
node.c \
- list.c \
node_list.c \
include/node.h \
- include/list.h \
include/node_list.h \
include/object.h
diff --git a/libcnary/include/list.h b/libcnary/include/list.h
deleted file mode 100644
index 6b18e6f..0000000
--- a/libcnary/include/list.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * list.h
- *
- * Created on: Mar 8, 2011
- * Author: posixninja
- *
- * Copyright (c) 2011 Joshua Hill. All Rights Reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef LIST_H_
-#define LIST_H_
-
-#include "object.h"
-
-typedef struct list_t {
- void* next;
- void* prev;
-} list_t;
-
-void list_init(struct list_t* list);
-void list_destroy(struct list_t* list);
-
-int list_add(struct list_t* list, struct object_t* object);
-int list_remove(struct list_t* list, struct object_t* object);
-
-#endif /* LIST_H_ */
diff --git a/libcnary/list.c b/libcnary/list.c
deleted file mode 100644
index 2f05347..0000000
--- a/libcnary/list.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * list.c
- *
- * Created on: Mar 8, 2011
- * Author: posixninja
- *
- * Copyright (c) 2011 Joshua Hill. All Rights Reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "list.h"
-
-void list_init(list_t* list) {
- list->next = NULL;
- list->prev = list;
-}
-
-
-void list_destroy(list_t* list) {
- if(list) {
- free(list);
- }
-}
-
-int list_add(list_t* list, object_t* object) {
- return -1;
-}
-
-int list_remove(list_t* list, object_t* object) {
- return -1;
-}
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