aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2008-01-20 17:34:53 -0600
committerRob Landley <rob@landley.net>2008-01-20 17:34:53 -0600
commit6ef04efa853b80c76ead2d252b3f4771f4c25d5d (patch)
tree527f7d3221c7147dbb5f8a8f0d057f2195bf6c9a /lib
parentb1aaba1fc8176ac0b7c202a664d2554aa0967116 (diff)
downloadtoybox-6ef04efa853b80c76ead2d252b3f4771f4c25d5d.tar.gz
Move dlist_add() to lib/llist.c
Diffstat (limited to 'lib')
-rw-r--r--lib/lib.h6
-rw-r--r--lib/llist.c14
2 files changed, 18 insertions, 2 deletions
diff --git a/lib/lib.h b/lib/lib.h
index afc3a8b2..ee073e0c 100644
--- a/lib/lib.h
+++ b/lib/lib.h
@@ -8,8 +8,6 @@
ssize_t getline(char **lineptr, size_t *n, FILE *stream);
// llist.c
-void llist_free(void *list, void (*freeit)(void *data));
-void *llist_pop(void *list); // actually void **list, but the compiler's dumb
struct string_list {
struct string_list *next;
@@ -27,6 +25,10 @@ struct double_list {
char *data;
};
+void llist_free(void *list, void (*freeit)(void *data));
+void *llist_pop(void *list); // actually void **list, but the compiler's dumb
+void dlist_add(struct double_list **list, char *data);
+
// args.c
void get_optflags(void);
diff --git a/lib/llist.c b/lib/llist.c
index 8d6fd265..4f9bc220 100644
--- a/lib/llist.c
+++ b/lib/llist.c
@@ -30,3 +30,17 @@ void *llist_pop(void *list)
return (void *)next;
}
+
+// Add an entry to the end off a doubly linked list
+void dlist_add(struct double_list **list, char *data)
+{
+ struct double_list *line = xmalloc(sizeof(struct double_list));
+
+ line->data = data;
+ if (*list) {
+ line->next = *list;
+ line->prev = (*list)->prev;
+ (*list)->prev->next = line;
+ (*list)->prev = line;
+ } else *list = line->next = line->prev = line;
+}