diff options
Diffstat (limited to 'src/ll.c')
| -rw-r--r-- | src/ll.c | 30 |
1 files changed, 28 insertions, 2 deletions
| @@ -1,12 +1,38 @@ | |||
| 1 | #include "ll.h" | 1 | #include "ll.h" |
| 2 | #include "ll-internal.h" | ||
| 3 | #include "shared.h" | 2 | #include "shared.h" |
| 4 | 3 | ||
| 5 | #include <stddef.h> | ||
| 6 | #include <stdlib.h> | 4 | #include <stdlib.h> |
| 7 | #include <errno.h> | 5 | #include <errno.h> |
| 8 | #include <error.h> | 6 | #include <error.h> |
| 9 | 7 | ||
| 8 | typedef struct dln { | ||
| 9 | void *data; | ||
| 10 | dll_freecb freecb; | ||
| 11 | |||
| 12 | struct dln *next; | ||
| 13 | struct dln *prev; | ||
| 14 | |||
| 15 | } dllnode; | ||
| 16 | typedef struct dlinked { | ||
| 17 | int size; | ||
| 18 | dllnode *start; | ||
| 19 | dllnode *end; | ||
| 20 | |||
| 21 | } dlinkedlist; | ||
| 22 | |||
| 23 | dllnode * dllnode_init(void *data, dll_freecb fcb) { | ||
| 24 | dllnode *n = VALLOC(1, sizeof(*n)); | ||
| 25 | if(!n) | ||
| 26 | return NULL; | ||
| 27 | |||
| 28 | n->data = data; | ||
| 29 | n->freecb = fcb; | ||
| 30 | n->prev = NULL; | ||
| 31 | n->next = NULL; | ||
| 32 | |||
| 33 | return n; | ||
| 34 | } | ||
| 35 | |||
| 10 | dlinkedlist * dlinkedlist_init(void) { | 36 | dlinkedlist * dlinkedlist_init(void) { |
| 11 | dlinkedlist *ll = VALLOC(1, sizeof(*ll)); | 37 | dlinkedlist *ll = VALLOC(1, sizeof(*ll)); |
| 12 | if(!ll) | 38 | if(!ll) |
