Re: Memory



martyn 2 russell bt com writes:
If I set the text on a label or a text box, do I need to free any memory?
Similarly if I set a pixmap to a new image, do I need to free the original
pixmap and/or should I free the new pixmap I created (i.e. does set_pixmap
create a copy and use that?)
 

set_pixmap adds a reference. So you have to remove your own reference.

set_text() will copy the string.

It's very rare (only one deprecated exception I can think of) that GTK
will "take over" ownership of a resource from you; typically it adds
its own reference, or makes a copy, and you have to unref/free your
copy.

With the subtlety of the floating refcount for GtkObject of course,
see GtkObject docs.

Havoc



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