whos to free what mem?



Hi,

I am developing GTK bindings for the language Eiffel and am currently
investigating who needs to free what memory with respect to strings.

In the following scenario:
---
GtkWidget *button;
char* label_text = ...; // somehow init that text
printf ("label text: %x\n", label_text);
button = gtk_button_new_with_label (label_text);
printf ("get_text: %x\n", gtk_button_get_label (GTK_BUTTON(button)));
---
I can see that gtk_button_new_with_label actually copies the string
since the first and the second printf show two different memory
locations. 

* Now am I correct when assuming that if I have dynamically allocated
the memory for 'label_text', it is my duty to free that memory again? 

* Is this true for all the string handling in GTK? Are strings always
copied, and I always need to free them? Or are there exceptions? If so
is there documentation who needs to free what where and when? (;

many thanks in advance,
Andreas

-- 




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