+/**
+ * Insert an element into a DLL before the given other element. Insert
+ * at the tail if the other element is NULL.
+ *
+ * @param head pointer to the head of the DLL
+ * @param tail pointer to the tail of the DLL
+ * @param other prior element, NULL for insertion at head of DLL
+ * @param element element to insert
+ */
+#define GNUNET_CONTAINER_DLL_insert_before(head,tail,other,element) do { \
+ GNUNET_assert ( ( (element)->prev == NULL) && ((head) != (element))); \
+ GNUNET_assert ( ( (element)->next == NULL) && ((tail) != (element))); \
+ (element)->next = (other); \
+ if (NULL == other) \
+ { \
+ (element)->prev = (tail); \
+ (tail) = (element); \
+ } \
+ else \
+ { \
+ (element)->prev = (other)->prev; \
+ (other)->prev = (element); \
+ } \
+ if (NULL == (element)->prev) \
+ (head) = (element); \
+ else \
+ (element)->prev->next = (element); } while (0)