This is faster than removing elements one by one. Will gain a user soon.
Signed-off-by: Emilio G. Cota <c...@braap.org> --- include/qemu/queue.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/qemu/queue.h b/include/qemu/queue.h index ac418efc43..0283c2dd7d 100644 --- a/include/qemu/queue.h +++ b/include/qemu/queue.h @@ -419,6 +419,16 @@ struct { \ (elm)->field.tqe_prev = NULL; \ } while (/*CONSTCOND*/0) +/* remove @left, @right and all elements in between from @head */ +#define QTAILQ_REMOVE_SEVERAL(head, left, right, field) do { \ + if (((right)->field.tqe_next) != NULL) \ + (right)->field.tqe_next->field.tqe_prev = \ + (left)->field.tqe_prev; \ + else \ + (head)->tqh_last = (left)->field.tqe_prev; \ + *(left)->field.tqe_prev = (right)->field.tqe_next; \ + } while (/*CONSTCOND*/0) + #define QTAILQ_FOREACH(var, head, field) \ for ((var) = ((head)->tqh_first); \ (var); \ -- 2.17.1