what to g_free and what to not.



Hello

In the process of making Gnome-GCJ (GTK/Gnome bindings for Java) I have
noticed that some methods that return strings (gchar*) sometimes allocate
a string for you, while some return one from static storage. For example,
gtk_widget_get_name basicly does "return widget->name", while
gtk_widget_get_composite_name and many other strdup the string before
returning it. Other examples are gtk_type_name which return a string
which shouldn't be freed, and gtk_accelerator_name which strdup's.

It's only the functions that return gchar* that I have checked. There
are others (for example those that retur gchar**) which need to checked
too.

Oskar Liljeblad (osk@hem.passagen.se)





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