Re: memory allocation/freeing




Helge Hess <hh@mdlink.de> writes:

> Hi,
> 
> I wonder who is considered maintaining memory with gtk.
> eg the function

Unfortunately, for returns it depends on the function. It should
be in the documentation, when there is documentation.

For arguments, GTK should never take ownership of the arguments,
although it may add an extra reference count if the argument
is a pointer to a reference counted object. 
 
However, there are may be exceptions to this rule. I.e., 
gtk_tooltips_set_colors() (As pointed out recently)
These should be considered be bugs.

> gchar *    gtk_editable_get_chars      (GtkEditable      *editable,
>                                         gint              start_pos,
>                                         gint              end_pos);
> 
> returns a (gchar *) pointer. When is it allocated/deallocated ...
> Do I have to deallocate the pointer ?

Here, yes.

> The same for setting:
> 
> void       gtk_editable_insert_text   (GtkEditable       *editable,
>                                        const gchar      *new_text,
>                                        gint
> new_text_length,
>                                        gint             *position);

The text will be copied from Nnew_text.

> Are all pointers given into gtk_* functions considered to be copied ?

See above.

Regards,
                                        Owen



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