On 03/23/2014 06:53 PM, Wenchao Xia wrote:
> 于 2014/3/21 6:53, Eric Blake 写道:
>> On 03/18/2014 11:16 PM, Wenchao Xia wrote:
>>> This file hold some functions that do not need to be generated.
>> s/hold/holds/
>>

>>> +
>>> +typedef struct QMPEventFunctions {
>>> +    QMPEventFuncEmit emit;
>>> +} QMPEventFunctions;
>>> +
>>> +QMPEventFunctions qmp_event_functions;
>>> +
>>> +void qmp_event_set_func_emit(QMPEventFuncEmit emit)
>>> +{
>>> +    qmp_event_functions.emit = emit;
>>> +}
>>> +
>>> +QMPEventFuncEmit qmp_event_get_func_emit(void)
>>> +{
>>> +    return qmp_event_functions.emit;
>>> +}
>> Is this struct a bit overkill, or do you extend it to include other
>> fields later?
>   No other fields will be added in this series, it allow different emit
> function hooked.
> Do you mean remove it and put it into generated qapi-event.c?

Keeping accessor functions is still a bit nicer than directly making a
global variable; but my point is that your accessors can just directly
access a static variable instead of wrapping things in a pointless struct:

static QMPEventFuncEmit qmp_emit;
void qmp_event_set_func_emit(QMPEventFuncEmit emit)
{
    qmp_emit = emit;
}
QMPEventFuncEmit qmp_event_get_func_emit(void)
{
    return qmp_emit;
}

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to