From c32a0e522f46525410a6d735c2d070a335e564d1 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Fri, 4 Oct 2019 18:01:39 +0200 Subject: [PATCH] MINOR: lists: add new macro LIST_SPLICE_END_DETACHED 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 | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/include/common/mini-clist.h b/include/common/mini-clist.h index 9e1033e09..9a81c9dd8 100644 --- a/include/common/mini-clist.h +++ b/include/common/mini-clist.h @@ -104,6 +104,19 @@ struct cond_wordlist { } \ } while (0) +/* adds the contents of a list whose first element is and last one is + * prev> at the end of another list . 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); }) -- 2.47.3