aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/lib.h3
-rw-r--r--lib/llist.c10
2 files changed, 12 insertions, 1 deletions
diff --git a/lib/lib.h b/lib/lib.h
index 09a68252..a71582c7 100644
--- a/lib/lib.h
+++ b/lib/lib.h
@@ -36,7 +36,8 @@ struct double_list {
};
void llist_traverse(void *list, void (*using)(void *data));
-void *llist_pop(void *list); // actually void **list, but the compiler's dumb
+void *llist_pop(void *list); // actually void **list
+void *dlist_pop(void *list); // actually struct double_list **list
void dlist_add_nomalloc(struct double_list **list, struct double_list *new);
struct double_list *dlist_add(struct double_list **list, char *data);
diff --git a/lib/llist.c b/lib/llist.c
index 7b41fd08..596da40f 100644
--- a/lib/llist.c
+++ b/lib/llist.c
@@ -33,6 +33,16 @@ void *llist_pop(void *list)
return (void *)next;
}
+void *dlist_pop(void *list)
+{
+ struct double_list **pdlist = (struct double_list **)list, *dlist = *pdlist;
+
+ dlist->next->prev = dlist->prev;
+ dlist->prev->next = *pdlist = dlist->next;
+
+ return dlist;
+}
+
void dlist_add_nomalloc(struct double_list **list, struct double_list *new)
{
if (*list) {