diff options
author | Steve Sistare <steven.sistare@oracle.com> | 2024-02-27 16:33:19 +0100 |
---|---|---|
committer | Markus Armbruster <armbru@redhat.com> | 2024-03-04 07:12:40 +0100 |
commit | 745736ae0cbe48dd7d58456baf084dc106320a87 (patch) | |
tree | 11ba3ad141f0b0c773a1c7450635918786ff64e3 /include/qapi | |
parent | 8a62ef7bd97c40e9f112d6c808898f907b11f65e (diff) | |
download | qemu-745736ae0cbe48dd7d58456baf084dc106320a87.zip qemu-745736ae0cbe48dd7d58456baf084dc106320a87.tar.gz qemu-745736ae0cbe48dd7d58456baf084dc106320a87.tar.bz2 |
qapi: New QAPI_LIST_LENGTH()
Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-ID: <20240227153321.467343-2-armbru@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'include/qapi')
-rw-r--r-- | include/qapi/util.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/include/qapi/util.h b/include/qapi/util.h index 81a2b13..20dfea8 100644 --- a/include/qapi/util.h +++ b/include/qapi/util.h @@ -56,4 +56,17 @@ int parse_qapi_name(const char *name, bool complete); (tail) = &(*(tail))->next; \ } while (0) +/* + * For any GenericList @list, return its length. + */ +#define QAPI_LIST_LENGTH(list) \ + ({ \ + size_t _len = 0; \ + typeof(list) _tail; \ + for (_tail = list; _tail != NULL; _tail = _tail->next) { \ + _len++; \ + } \ + _len; \ + }) + #endif |