qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v5 03/46] qapi: Test for C member name collision


From: Markus Armbruster
Subject: Re: [Qemu-devel] [PATCH v5 03/46] qapi: Test for C member name collisions
Date: Wed, 23 Sep 2015 17:12:13 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

Eric Blake <address@hidden> writes:

> On 09/23/2015 08:02 AM, Markus Armbruster wrote:
>
>>> However, I'm not sure it would always help.  The conversion of
>>> netdev_add to full qapi relies on being able to access the variant
>>> through a named struct (such as NetdevTapOptions); unboxing the variant
>>> would get rid of the convenient access to these named sub-structs.
>> 
>> struct Union {
>>     EnumType type;
>>     /* union tag is @type */
>>     union {
>>         One one;
>>         Two two;
>>     };
>> };
>> 
>> For base, we go one step further and peel off the struct, to save some
>> notational overhead.  Pointless for unions.
>
> Ah, I see. Instead of malloc'ing a sub-struct and calling (roughly)
>
> ptr = visit_start_struct(Union) // mallocs
> subptr = visit_start_implicit_struct(One) // also mallocs
> visit_type_fields(subptr)
> visit_end_implicit_struct()
>
> we would instead use inline allocation, with:
>
> ptr = visit_start_struct(Union) // mallocs
> visit_type_fields(&ptr->one)
>
> seems straightforward enough; I'll play with the idea on top of my series.

I should be careful what I wish for lest the series grows faster than I
can review it!



reply via email to

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