r12601: Syncronise both copies of dlinklist.h.
authorAndrew Bartlett <abartlet@samba.org>
Fri, 30 Dec 2005 08:57:33 +0000 (08:57 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:49:01 +0000 (13:49 -0500)
Should we somehow link these, or just use the version in ldb?

Andrew Bartlett
(This used to be commit e98d14668e3fdee01b103adb5aec733790eee96d)

source4/include/dlinklist.h
source4/lib/ldb/include/dlinklist.h

index d50a46c5d43c82dad7b35398b0953cb725ed0552..176c138aafa6ac4c6298c337045fb4f4a9e31e26 100644 (file)
 /* To use these macros you must have a structure containing a next and
    prev pointer */
 
-struct dlist_item {
-       struct dlist_item *prev, *next;
-       void *ptr;      
-};
 
 /* hook into the front of the list */
 #define DLIST_ADD(list, p) \
@@ -88,3 +84,26 @@ do { \
                if (p->next) p->next->prev = p; \
        }\
 } while (0)
+
+/* demote an element to the end of the list, needs a tmp pointer */
+#define DLIST_DEMOTE(list, p, tmp) \
+do { \
+               DLIST_REMOVE(list, p); \
+               DLIST_ADD_END(list, p, tmp); \
+} while (0)
+
+/* concatenate two lists - putting all elements of the 2nd list at the
+   end of the first list */
+#define DLIST_CONCATENATE(list1, list2, type) \
+do { \
+               if (!(list1)) { \
+                       (list1) = (list2); \
+               } else { \
+                       type tmp; \
+                       for (tmp = (list1); tmp->next; tmp = tmp->next) ; \
+                       tmp->next = (list2); \
+                       if (list2) { \
+                               (list2)->prev = tmp;    \
+                       } \
+               } \
+} while (0)
index a39007375f355a7225cda93d19e15ac97601d8c3..176c138aafa6ac4c6298c337045fb4f4a9e31e26 100644 (file)
@@ -71,6 +71,20 @@ do { \
                } \
 } while (0)
 
+/* 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 end of the list, needs a tmp pointer */
 #define DLIST_DEMOTE(list, p, tmp) \
 do { \