RE: The iterator interface



On Mon, 2006-08-07 at 10:49 +0200, Philip Van Hoof wrote:
> On Mon, 2006-08-07 at 11:31 +0300, Dirk-Jan Binnema nokia com wrote:
> > That sounds like a good plan; make 'm void. And then maybe add 
> > ref'ing and non-ref'ing versions of _current, maybe with a bool flag?
> > 
> > ie.
> > GObject* tny_iterator_iface_current (const TnyIteratorIface *self,
> > gboolean add_ref);
>
> I agree but without the boolean flag. I think it's better to simply be
> consistent and always add the reference.

I'm currently writing a more details response to the original post, but
I'd agree with Phillip here. The whole point of doing this would be to
fix potential thread-safety issues, and letting people pass FALSE for
"add ref" would just be putting those issues back in again.

If for some reason you can't cope with handling reference-counting
properly, you can always call g_object_unref directly after you get the
object. I think making it always return an added reference would be
better, because it means that people who don't understand this
particular issue will do it the safe way, rather then making it easier
for them to write broken code without realising it.


Cheers,

James "Doc" Livingston
-- 
As easy as 3.14159265358979323846264338327950288419716




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