mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-08 08:07:10 +02:00
MINOR: list: add LIST_SPLICE() to merge one list into another
This will move the contents of list <old> at the beginning of list <new>.
This commit is contained in:
parent
02bac85bee
commit
9bead8c7f5
@ -86,6 +86,14 @@ struct cond_wordlist {
|
|||||||
/* adds an element at the end of a list ; returns the element */
|
/* adds an element at the end of a list ; returns the element */
|
||||||
#define LIST_ADDQ(lh, el) ({ (el)->p = (lh)->p; (el)->p->n = (lh)->p = (el); (el)->n = (lh); (el); })
|
#define LIST_ADDQ(lh, el) ({ (el)->p = (lh)->p; (el)->p->n = (lh)->p = (el); (el)->n = (lh); (el); })
|
||||||
|
|
||||||
|
/* adds the contents of a list <old> at the beginning of another list <new>. The old list head remains untouched. */
|
||||||
|
#define LIST_SPLICE(new, old) do { \
|
||||||
|
if (!LIST_ISEMPTY(old)) { \
|
||||||
|
(old)->p->n = (new)->n; (old)->n->p = (new); \
|
||||||
|
(new)->n->p = (old)->p; (new)->n = (old)->n; \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
/* removes an element from a list and returns it */
|
/* 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); })
|
#define LIST_DEL(el) ({ typeof(el) __ret = (el); (el)->n->p = (el)->p; (el)->p->n = (el)->n; (__ret); })
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user