]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
liblib: Added DLLIST2_INSERT_AFTER_FULL()
authorStephan Bosch <stephan@rename-it.nl>
Wed, 17 Apr 2013 15:47:36 +0000 (18:47 +0300)
committerStephan Bosch <stephan@rename-it.nl>
Wed, 17 Apr 2013 15:47:36 +0000 (18:47 +0300)
For inserting a new element in a doubly-linked list after an existing
element.

src/lib/llist.h

index 16c7d3741a0b4863ae97a326f8c6b27dd222de42..bb4b92b083f57927d45e1283d8f2e9dd279c95ae 100644 (file)
 #define DLLIST2_APPEND(head, tail, item) \
        DLLIST2_APPEND_FULL(head, tail, item, prev, next)
 
+#define DLLIST2_INSERT_AFTER_FULL(head, tail, after, item, prev, next) \
+       STMT_START { \
+       (item)->prev = (after); \
+       (item)->next = (after)->next; \
+       (after)->next = (item); \
+       if (*(tail) == (after)) \
+               *(tail) = (item); \
+       } STMT_END
+
+#define DLLIST2_INSERT_AFTER(head, tail, after, item) \
+       DLLIST2_INSERT_AFTER_FULL(head, tail, after, item, prev, next)
+
 #define DLLIST2_REMOVE_FULL(head, tail, item, prev, next) STMT_START { \
        if ((item)->prev == NULL) \
                *(head) = (item)->next; \