summaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/util')
-rw-r--r--src/util/dlinklist.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/util/dlinklist.h b/src/util/dlinklist.h
index be5ff914..f323de70 100644
--- a/src/util/dlinklist.h
+++ b/src/util/dlinklist.h
@@ -110,6 +110,22 @@ do { \
} \
} while (0)
+/* insert all elements from list2 after the given element 'el' in the
+ * first list */
+#define DLIST_ADD_LIST_AFTER(list1, el, list2, type) \
+do { \
+ if (!(list1) || !(el) || !(list2)) { \
+ DLIST_CONCATENATE(list1, list2, type); \
+ } else { \
+ type tmp; \
+ for (tmp = (list2); tmp->next; tmp = tmp->next) ; \
+ (list2)->prev = (el); \
+ tmp->next = (el)->next; \
+ (el)->next = (list2); \
+ if ((el)->next != NULL) (el)->next->prev = tmp; \
+ } \
+} while (0);
+
#define DLIST_FOR_EACH(p, list) \
for ((p) = (list); (p) != NULL; (p) = (p)->next)