Re: gtk_tree_model_get() malloc/free question



Mike wrote:

Hello,

I always tend to get confused with this sort of thing.

The docs say:
http://developer.gnome.org/doc/API/2.0/gtk/GtkTreeModel.html#gtk-tree-model-get
"you would write: gtk_tree_model_get (model, iter, 0,
&place_string_here, -1), where place_string_here is a gchar* to be
filled with the string. If appropriate, the returned values have to be
freed or unreferenced."

But I'm not sure that tells me if I need to g_malloc "place_string_here"
and free it when I'm done or if I'm going to be passed a copy of the
string that I need to free afterwards or if I'm passed a copy of the
pointer that I ignore when I'm done with it. I've tried it by both
allocating memory and freeing it and by just passing it a pointer and
both *seem* to work so I'm not real clear on how I should handle it.

Regards.




_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

My understanding is that a newly allocated string is passed to you which you must free. You need not g_malloc it.

Martyn




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