summaryrefslogtreecommitdiff
path: root/source3/include/dlinklist.h
diff options
context:
space:
mode:
Diffstat (limited to 'source3/include/dlinklist.h')
-rw-r--r--source3/include/dlinklist.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/source3/include/dlinklist.h b/source3/include/dlinklist.h
index 794aea7576..c856aaa762 100644
--- a/source3/include/dlinklist.h
+++ b/source3/include/dlinklist.h
@@ -70,6 +70,20 @@
} \
}
+/* insert 'p' after the given element 'el' in a list. If el is NULL then
+ this is the same as a DLIST_ADD() */
+#define DLIST_ADD_AFTER(list, p, el) \
+do { \
+ if (!(list) || !(el)) { \
+ DLIST_ADD(list, p); \
+ } else { \
+ p->prev = el; \
+ p->next = el->next; \
+ el->next = p; \
+ if (p->next) p->next->prev = p; \
+ }\
+} while (0)
+
/* demote an element to the top of the list, needs a tmp pointer */
#define DLIST_DEMOTE(list, p, tmp) \
{ \