[pacman-dev] [PATCH] events: Make alpm_event_t an union of all event-specific struct
Olivier Brunel
jjk at jjacky.com
Mon Jun 23 10:53:43 EDT 2014
On 06/23/14 14:31, Allan McRae wrote:
> On 16/06/14 03:43, Olivier Brunel wrote:
>> Signed-off-by: Olivier Brunel <jjk at jjacky.com>
>> ---
>> Similar as changes done re: questions.
>
> I like this better than the old approach. One query...
>
>>
>> lib/libalpm/alpm.h | 29 ++++++++++++++++++++++-------
>> src/pacman/callback.c | 25 ++++++++++++-------------
>> 2 files changed, 34 insertions(+), 20 deletions(-)
>>
>> diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h
>> index b0adb95..ffd71c6 100644
>> --- a/lib/libalpm/alpm.h
>> +++ b/lib/libalpm/alpm.h
>> @@ -361,15 +361,10 @@ typedef enum _alpm_event_type_t {
>> ALPM_EVENT_PACORIG_CREATED
>> } alpm_event_type_t;
>>
>> -/** Events.
>> - * This is a generic struct this is passed to the callback, that allows the
>> - * frontend to know which type of event was triggered. It is then possible to
>> - * typecast the pointer to the right structure, in order to access
>> - * event-specific data. */
>> -typedef struct _alpm_event_t {
>> +typedef struct _alpm_event_any_t {
>> /** Type of event. */
>> alpm_event_type_t type;
>> -} alpm_event_t;
>> +} alpm_event_any_t;
>
> Why is this kept?
It is indeed (basically) useless; I did it for "consistency," as in it
seemed a standard/common thing when dealing with such union to have a
field "any" with common attributes (even though here there isn't
actually any), including in alpm_question_t. So it just felt like a good
idea wrt consistency to have one for events as well... but you can
remove it if you feel it is only useless.
>
>
>
>
More information about the pacman-dev
mailing list