[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH V9 12/46] qapi: QAPI_LIST_LENGTH
From: |
Steve Sistare |
Subject: |
[PATCH V9 12/46] qapi: QAPI_LIST_LENGTH |
Date: |
Tue, 26 Jul 2022 09:10:09 -0700 |
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
- [PATCH V9 00/46] Live Update, Steve Sistare, 2022/07/26
- [PATCH V9 12/46] qapi: QAPI_LIST_LENGTH,
Steve Sistare <=
- [PATCH V9 03/46] migration: file URI, Steve Sistare, 2022/07/26
- [PATCH V9 02/46] memory: RAM_NAMED_FILE flag, Steve Sistare, 2022/07/26
- [PATCH V9 01/46] migration: fix populate_vfio_info, Steve Sistare, 2022/07/26
- [PATCH V9 14/46] qapi: strList unit tests, Steve Sistare, 2022/07/26
- [PATCH V9 13/46] qapi: strv_from_strList, Steve Sistare, 2022/07/26
- [PATCH V9 18/46] memory: flat section iterator, Steve Sistare, 2022/07/26
- [PATCH V9 04/46] migration: mode parameter, Steve Sistare, 2022/07/26
- [PATCH V9 21/46] cpr: preserve extra state, Steve Sistare, 2022/07/26
- [PATCH V9 19/46] oslib: qemu_clear_cloexec, Steve Sistare, 2022/07/26
- [PATCH V9 30/46] vfio-pci: refactor for cpr, Steve Sistare, 2022/07/26