Emilio G. Cota <c...@braap.org> writes:

> 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;      \

This seems wrong, shouldn't it be:

  (left)->field.tqe_prev->field.tqe_next = (right)->field.tqe_next;

Although to be honest every time I read the QUEUE macros I end up with a 
headache...

> +    } while (/*CONSTCOND*/0)
> +
>  #define QTAILQ_FOREACH(var, head, field)                                \
>          for ((var) = ((head)->tqh_first);                               \
>                  (var);                                                  \


--
Alex Bennée

Reply via email to