qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [RFC v2 07/38] queue: add QTAILQ_REMOVE_SEVERAL


From: Emilio G. Cota
Subject: [Qemu-devel] [RFC v2 07/38] queue: add QTAILQ_REMOVE_SEVERAL
Date: Sun, 9 Dec 2018 14:37:18 -0500

This is faster than removing elements one by one.

Will gain a user soon.

Signed-off-by: Emilio G. Cota <address@hidden>
---
 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]