Re: gtk_tree_model_get_iter_first



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




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