Re: what to g_free and what to not.




Oskar Liljeblad <osk@hem.passagen.se> writes:

> 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.

It's a known, much debated, issue. We certainly can't start
changing the existing functions to behave differently! So the
question is coming up with some sort of solution that allows
us to have a consistent way of doing things in the future.

                                        Owen





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