aboutsummaryrefslogtreecommitdiff
path: root/lib/llist.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/llist.c')
-rw-r--r--lib/llist.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/llist.c b/lib/llist.c
index 2d5bc97a..6b4b8f2c 100644
--- a/lib/llist.c
+++ b/lib/llist.c
@@ -85,3 +85,17 @@ struct double_list *dlist_add(struct double_list **list, char *data)
return new;
}
+
+// Terminate circular list for traversal in either direction. Returns end *.
+void *dlist_terminate(void *list)
+{
+ struct double_list *end = list;
+
+ if (!list) return 0;
+
+ end = end->prev;
+ end->next->prev = 0;
+ end->next = 0;
+
+ return end;
+}