diff options
| -rw-r--r-- | libcnary/Makefile.am | 2 | ||||
| -rw-r--r-- | libcnary/include/list.h | 40 | ||||
| -rw-r--r-- | libcnary/list.c | 47 | ||||
| -rw-r--r-- | libcnary/node_list.c | 11 |
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 = | |||
| 6 | libcnary_la_LDFLAGS = $(AM_LDFLAGS) -no-undefined | 6 | libcnary_la_LDFLAGS = $(AM_LDFLAGS) -no-undefined |
| 7 | libcnary_la_SOURCES = \ | 7 | libcnary_la_SOURCES = \ |
| 8 | node.c \ | 8 | node.c \ |
| 9 | list.c \ | ||
| 10 | node_list.c \ | 9 | node_list.c \ |
| 11 | include/node.h \ | 10 | include/node.h \ |
| 12 | include/list.h \ | ||
| 13 | include/node_list.h \ | 11 | include/node_list.h \ |
| 14 | include/object.h | 12 | 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 @@ | |||
| 1 | /* | ||
| 2 | * list.h | ||
| 3 | * | ||
| 4 | * Created on: Mar 8, 2011 | ||
| 5 | * Author: posixninja | ||
| 6 | * | ||
| 7 | * Copyright (c) 2011 Joshua Hill. All Rights Reserved. | ||
| 8 | * | ||
| 9 | * This library is free software; you can redistribute it and/or | ||
| 10 | * modify it under the terms of the GNU Lesser General Public | ||
| 11 | * License as published by the Free Software Foundation; either | ||
| 12 | * version 2.1 of the License, or (at your option) any later version. | ||
| 13 | * | ||
| 14 | * This library is distributed in the hope that it will be useful, | ||
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 17 | * Lesser General Public License for more details. | ||
| 18 | * | ||
| 19 | * You should have received a copy of the GNU Lesser General Public | ||
| 20 | * License along with this library; if not, write to the Free Software | ||
| 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 22 | */ | ||
| 23 | |||
| 24 | #ifndef LIST_H_ | ||
| 25 | #define LIST_H_ | ||
| 26 | |||
| 27 | #include "object.h" | ||
| 28 | |||
| 29 | typedef struct list_t { | ||
| 30 | void* next; | ||
| 31 | void* prev; | ||
| 32 | } list_t; | ||
| 33 | |||
| 34 | void list_init(struct list_t* list); | ||
| 35 | void list_destroy(struct list_t* list); | ||
| 36 | |||
| 37 | int list_add(struct list_t* list, struct object_t* object); | ||
| 38 | int list_remove(struct list_t* list, struct object_t* object); | ||
| 39 | |||
| 40 | #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 @@ | |||
| 1 | /* | ||
| 2 | * list.c | ||
| 3 | * | ||
| 4 | * Created on: Mar 8, 2011 | ||
| 5 | * Author: posixninja | ||
| 6 | * | ||
| 7 | * Copyright (c) 2011 Joshua Hill. All Rights Reserved. | ||
| 8 | * | ||
| 9 | * This library is free software; you can redistribute it and/or | ||
| 10 | * modify it under the terms of the GNU Lesser General Public | ||
| 11 | * License as published by the Free Software Foundation; either | ||
| 12 | * version 2.1 of the License, or (at your option) any later version. | ||
| 13 | * | ||
| 14 | * This library is distributed in the hope that it will be useful, | ||
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 17 | * Lesser General Public License for more details. | ||
| 18 | * | ||
| 19 | * You should have received a copy of the GNU Lesser General Public | ||
| 20 | * License along with this library; if not, write to the Free Software | ||
| 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 22 | */ | ||
| 23 | |||
| 24 | #include <stdio.h> | ||
| 25 | #include <stdlib.h> | ||
| 26 | |||
| 27 | #include "list.h" | ||
| 28 | |||
| 29 | void list_init(list_t* list) { | ||
| 30 | list->next = NULL; | ||
| 31 | list->prev = list; | ||
| 32 | } | ||
| 33 | |||
| 34 | |||
| 35 | void list_destroy(list_t* list) { | ||
| 36 | if(list) { | ||
| 37 | free(list); | ||
| 38 | } | ||
| 39 | } | ||
| 40 | |||
| 41 | int list_add(list_t* list, object_t* object) { | ||
| 42 | return -1; | ||
| 43 | } | ||
| 44 | |||
| 45 | int list_remove(list_t* list, object_t* object) { | ||
| 46 | return -1; | ||
| 47 | } | ||
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 |
