Thank you for your feedback. It just seemed to me that we could do away with one more variable if the boolean were not there. I guess allocating the iterator on the stack rather than on the heap is faster, and makes sense since as you said iterators are meant to be used for looping and are not expected to be used beyond block scope, so by having them on the stack you need not free them. Interesting explanation. Others welcome...
Best Regards, Neil On Wed, 24 Nov 2004 23:29:51 +0000, Tim Müller <[EMAIL PROTECTED]> wrote: > On Wednesday 24 November 2004 23:03, Neil Zanella wrote: > > > > > I would like to know how come gtk_tree_model_get_iter_first doesn't > > just return a GtkTreeIter and set it to NULL when the end of the > > iteration is reached rather than returning a boolean? Why is the design of > > the API such that it returns a boolean instead? Wouldn't the approach I > > describe simplify the API? > > If it returned a pointer to a GtkTreeIter, it would need to dynamically > allocate memory for that, which you would need to later free yourself as > well. It's more efficient to allocate the iter on the stack, and have > gtk_tree_model_get_iter_first() fill in the values. Also, you're not supposed > to keep iters around for longer than absolutely necessary, so dynamic > allocation doesn't really make sense in most cases. > > I find the approach where a boolean is returned makes the code actually > clearer and more legible, but maybe that's just me. > > Cheers > -Tim > > _______________________________________________ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list