qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH V2 0/4] string list functions


From: Markus Armbruster
Subject: Re: [PATCH V2 0/4] string list functions
Date: Fri, 10 Feb 2023 09:57:11 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)

Daniel P. Berrangé <berrange@redhat.com> writes:

> On Tue, Feb 07, 2023 at 10:48:43AM -0800, Steve Sistare wrote:
>> Add some handy string list functions, for general use now, and for
>> eventual use in the cpr/live update patches.
>> 
>> Steve Sistare (4):
>>   qapi: strList_from_string
>>   qapi: QAPI_LIST_LENGTH
>>   qapi: strv_from_strList
>>   qapi: strList unit tests
>
> I know that the 'strList' type falls out naturally from the
> QAPI type generator for arrays, but I've always considered
> it to be a rather awkward result.  The normal C approach
> would be to use 'char **' NULL terminated, which conveniently
> already has a bunch of helper APIs from glib, and is also
> accepted or returned by various other functions we might
> like to use.
>
> Should we consider making the QAPI generator handle string
> lists as a special case, emitting 'char **' instead of this
> series ?

I don't like special cases.  I also don't like GenericList in any case.

I believe a linked list was chosen because it results in a fairly simple
visitor interface and implementation.  But it's a poor data structure
for a homogeneous sequence that rarely if ever changes: lots of pointer
chasing, waste of memory when the elements are small.

Output visitors walk the sequence in order.  An array would be perfect.

Input visitors build the sequence by appending elements in order.
A flexible array like GArray would do.

I'm not aware of other code mutating GenericLists or its descendants.
It might exist.  I'd be surprised if there's much of it, though.




reply via email to

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