]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: lists: add new macro LIST_SPLICE_END_DETACHED
authorWilly Tarreau <w@1wt.eu>
Fri, 4 Oct 2019 16:01:39 +0000 (18:01 +0200)
committerOlivier Houchard <cognet@ci0.org>
Fri, 11 Oct 2019 14:37:41 +0000 (16:37 +0200)
This macro adds a detached list at the end of an existing
list. The detached list is a list without head, containing
only elements.

include/common/mini-clist.h

index 9e1033e09f3787f55df593415ea5536902bac751..9a81c9dd8a5b28f21707d4dbe0e239b69f26d18f 100644 (file)
@@ -104,6 +104,19 @@ struct cond_wordlist {
                }                                                    \
        } while (0)
 
+/* adds the contents of a list whose first element is <old> and last one is
+ * <old->prev> at the end of another list <new>. The old list DOES NOT have
+ * any head here.
+ */
+#define LIST_SPLICE_END_DETACHED(new, old) do {              \
+               typeof(new) __t;                             \
+               (new)->p->n = (old);                         \
+               (old)->p->n = (new);                         \
+               __t = (old)->p;                              \
+               (old)->p = (new)->p;                         \
+               (new)->p = __t;                              \
+       } while (0)
+
 /* removes an element from a list and returns it */
 #define LIST_DEL(el) ({ typeof(el) __ret = (el); (el)->n->p = (el)->p; (el)->p->n = (el)->n; (__ret); })