[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH V2 2/4] qapi: QAPI_LIST_LENGTH
From: |
Steve Sistare |
Subject: |
[PATCH V2 2/4] qapi: QAPI_LIST_LENGTH |
Date: |
Tue, 7 Feb 2023 10:48:45 -0800 |
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
- Re: [PATCH V2 1/4] qapi: strList_from_string, (continued)
- Re: [PATCH V2 1/4] qapi: strList_from_string, Steven Sistare, 2023/02/08
- Re: [PATCH V2 1/4] qapi: strList_from_string, Markus Armbruster, 2023/02/09
- Re: [PATCH V2 1/4] qapi: strList_from_string, Steven Sistare, 2023/02/09
- Re: [PATCH V2 1/4] qapi: strList_from_string, Markus Armbruster, 2023/02/09
- Re: [PATCH V2 1/4] qapi: strList_from_string, Steven Sistare, 2023/02/09
- Re: [PATCH V2 1/4] qapi: strList_from_string, Markus Armbruster, 2023/02/09
- Re: [PATCH V2 1/4] qapi: strList_from_string, Steven Sistare, 2023/02/09
- Re: [PATCH V2 1/4] qapi: strList_from_string, Markus Armbruster, 2023/02/10
[PATCH V2 3/4] qapi: strv_from_strList, Steve Sistare, 2023/02/07
[PATCH V2 4/4] qapi: strList unit tests, Steve Sistare, 2023/02/07
[PATCH V2 2/4] qapi: QAPI_LIST_LENGTH,
Steve Sistare <=
Re: [PATCH V2 0/4] string list functions, Markus Armbruster, 2023/02/09
Re: [PATCH V2 0/4] string list functions, Daniel P . Berrangé, 2023/02/09