aboutsummaryrefslogtreecommitdiff
path: root/dlist.c
diff options
context:
space:
mode:
Diffstat (limited to 'dlist.c')
-rw-r--r--dlist.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/dlist.c b/dlist.c
new file mode 100644
index 0000000..766f940
--- /dev/null
+++ b/dlist.c
@@ -0,0 +1,35 @@
+struct LIST *
+LIST_UNLINK(struct LIST **root, struct LIST *p)
+{
+ if (p->prev)
+ p->prev->next = p->next;
+ else
+ *root = p->next;
+ if (p->next)
+ p->next->prev = p->prev;
+ p->next = p->prev = NULL;
+ return p;
+}
+
+struct LIST *
+LIST_POP(struct LIST **pp)
+{
+ if (*pp)
+ return LIST_UNLINK(pp, *pp);
+ return NULL;
+}
+
+void
+LIST_PUSH(struct LIST **pp, struct LIST *p)
+{
+ p->prev = NULL;
+ p->next = *pp;
+ if (*pp)
+ (*pp)->prev = p;
+ *pp = p;
+}
+
+#undef LIST
+#undef LIST_PUSH
+#undef LIST_POP
+#undef LIST_UNLINK

Return to:

Send suggestions and report system problems to the System administrator.