RE: freeing GTK+ memory



To revive this thread...

The question of whether I need to free memory returned to me from various GTK functions is something that I've more than once found pretty confusing with not much help from the documentation, and here's an example that I just came across:

The documentation for gtk_radio_button_get_group() says that it returns a GSList*, but is that a list that it allocated for me so I will need to free it, or is it a pointer to an internal GSList that I must not free? A call to g_slist_free() didn't break anything so presumably that's the correct thing to do, but "try it and see" like that is not really the ideal way to design an app.

Some functions are well documented in this respect - like gtk_button_get_label() says that the returned string "is owned by the widget and must not be modified or freed", and gtk_container_get_children() says that it returns "a newly-allocated list" which implies the need to free it. But I've come across a few like the above that left me guessing.

Ian





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