On Sat, Apr 30, 2011 at 4:59 PM, Gustavo Sverzut Barbieri
<[email protected]> wrote:
> On Fri, Apr 29, 2011 at 3:54 PM, Enlightenment SVN
> <[email protected]> wrote:
>> Log:
>> Eina refcount: Wrap EINA_REFCOUNT_UNREF with do {} while(0).
>>  #define EINA_REFCOUNT_UNREF(Variable, Free_Callback) \
>> -  if (--((Variable)->__refcount) == 0)              \
>> -    Free_Callback(Variable);
>> +   do                                                \
>> +     {                                               \
>> +        if (--((Variable)->__refcount) == 0)         \
>> +           Free_Callback(Variable);                  \
>> +     }                                               \
>> +   while (0)
>
> maybe think of a way to set Free_Callback automatically? Spread this
> all around the code will be bad?

Yup, that what I would have liked to do, but didn't come up with a
clean solution for it.

> One clear way would be to waste some memory and hook
> (Variable)->__refcount_free_cb, but that's a pointer per object and
> not good. Other way is to somehow register based on classes.

Yes, you found the issue. I don't know of a clean solution to this
problem. The only possible solution is to add this to eina_object and
have it for free. But that force us to use eina_object when we just
want refcount, so not a good solution either.

> The current way is too error prone IMO.

Agreed, but better than nothing.
-- 
Cedric BAIL

------------------------------------------------------------------------------
WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network 
management toolset available today.  Delivers lowest initial 
acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd
_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to