"Michael S. Tsirkin" <[email protected]> writes: > On Mon, Oct 06, 2025 at 04:38:32PM +0200, Markus Armbruster wrote: >> "Michael S. Tsirkin" <[email protected]> writes: >> > However, QAPI_LIST_FOR_EACH can potentially be used to implement >> > QAPI_LIST_LENGTH. >> > >> > #define QAPI_LIST_FOR_EACH(list, tail) \ >> > for (tail = list; tail != NULL; tail = tail->next) >> > >> > and >> > >> > #define QAPI_LIST_LENGTH(list) \ >> > ({ \ >> > size_t _len = 0; \ >> > typeof_strip_qual(list) _tail; \ >> > QAPI_LIST_FOR_EACH(list, tail) { \ >> > _len++; \ >> > } \ >> > _len; \ >> > }) >> >> Yes, but would QAPI_LIST_FOR_EACH be better than the straightfoward & >> simple for-loop? >> >> [...] > > Well I don't really remember off hand how QAPI lists work so for me I'd > have to otherwise go read the code to check this is the right way to > walk this list. > > Which reminds me, why are these custom like this and not just QLIST?
Beats me, I inherited them :) A linked list would not be my choice for representing JSON arrays. Bigger fish to fry...
