aboutsummaryrefslogtreecommitdiff
path: root/lib/llist.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/llist.c')
-rw-r--r--lib/llist.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/llist.c b/lib/llist.c
index 2969102d..e1e6a564 100644
--- a/lib/llist.c
+++ b/lib/llist.c
@@ -51,6 +51,7 @@ void *llist_pop(void *list)
return (void *)next;
}
+// Remove first item from &list and return it
void *dlist_pop(void *list)
{
struct double_list **pdlist = (struct double_list **)list, *dlist = *pdlist;
@@ -66,6 +67,21 @@ void *dlist_pop(void *list)
return dlist;
}
+// remove last item from &list and return it (stack pop)
+void *dlist_lpop(void *list)
+{
+ struct double_list *dl = *(struct double_list **)list;
+ void *v = 0;
+
+ if (dl) {
+ dl = dl->prev;
+ v = dlist_pop(&dl);
+ if (!dl) *(void **)list = 0;
+ }
+
+ return v;
+}
+
void dlist_add_nomalloc(struct double_list **list, struct double_list *new)
{
if (*list) {