qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH V8 15/39] qapi: QAPI_LIST_LENGTH


From: Marc-André Lureau
Subject: Re: [PATCH V8 15/39] qapi: QAPI_LIST_LENGTH
Date: Thu, 16 Jun 2022 20:06:19 +0400

Hi

On Wed, Jun 15, 2022 at 7:38 PM Steve Sistare <steven.sistare@oracle.com> wrote:
Signed-off-by: Steve Sistare <steven.sistare@oracle.com>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
 
---
 include/qapi/util.h | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/include/qapi/util.h b/include/qapi/util.h
index 7d88b09..75dddca 100644
--- a/include/qapi/util.h
+++ b/include/qapi/util.h
@@ -65,4 +65,17 @@ struct strList *strList_from_string(const char *in, char delim);
     (tail) = &(*(tail))->next; \
 } while (0)

+/*
+ * For any GenericList @list, return its length.
+ */
+#define QAPI_LIST_LENGTH(list) \
+    ({ \
+        int len = 0; \
+        typeof(list) elem; \
+        for (elem = list; elem != NULL; elem = elem->next) { \
+            len++; \
+        } \
+        len; \
+    })
+
 #endif
--
1.8.3.1




--
Marc-André Lureau

reply via email to

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