swrap: Add SWRAP_DLIST_ADD_AFTER macro
authorMichael Adam <obnox@samba.org>
Tue, 16 Aug 2016 09:00:50 +0000 (11:00 +0200)
committerAndreas Schneider <asn@samba.org>
Thu, 20 Oct 2016 08:50:22 +0000 (10:50 +0200)
Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>

Signed-off-by: Michael Adam <obnox@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
src/socket_wrapper.c

index 5cb494cd03b29499d5621cceb0b0a9ecd5aa8767..2a88dff6a5d981633fb7995ab4d1afc19aa5c3d3 100644 (file)
@@ -184,6 +184,20 @@ enum swrap_dbglvl_e {
        (item)->next    = NULL; \
 } while (0)
 
+#define SWRAP_DLIST_ADD_AFTER(list, item, el) \
+do { \
+       if ((list) != NULL || (el) != NULL) { \
+               SWRAP_DLIST_ADD(list, item); \
+       } else { \
+               (item)->prev = (el); \
+               (item)->next = (el)->next; \
+               (el)->next = (item); \
+               if ((item)->next != NULL) { \
+                       (item)->next->prev = (item); \
+               } \
+       } \
+} while (0)
+
 #if defined(HAVE_GETTIMEOFDAY_TZ) || defined(HAVE_GETTIMEOFDAY_TZ_VOID)
 #define swrapGetTimeOfDay(tval) gettimeofday(tval,NULL)
 #else