diff lib/llist.c @ 238:630b2e12db16

Move dlist_add() to lib/llist.c
author Rob Landley <rob@landley.net>
date Sun, 20 Jan 2008 17:34:53 -0600
parents 3981c96f9285
children aaac01796688
line wrap: on
line diff
--- a/lib/llist.c	Sun Jan 20 17:25:44 2008 -0600
+++ b/lib/llist.c	Sun Jan 20 17:34:53 2008 -0600
@@ -30,3 +30,17 @@
 
 	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;
+}