Re: Memory Leak?

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

 



Hi.
>         I'm just learning how to use g_object_get and was wondering if this> function contained a memory leak:> static void color_changed(GtkColorButton *caller, GtkWidget *label) {>     GdkColor *color;>>     g_object_get(caller, "color", &color, NULL);>     gtk_widget_modify_fg(label, GTK_STATE_NORMAL, color);> }
Yes, this function leaks. GdkColor is GBoxed, which means that isbeaing copied when you call g_object_get. You should free it withgdk_color_free( color ) or g_boxed_free( GDK_TYPE_COLOR, color )before returning from callback.
-- Tadej Borovšaktadeboro.blogspot.comtadeboro@xxxxxxxxxxxxxxxxxxxxxxx@gmail.com_______________________________________________gtk-list mailing listgtk-list@xxxxxxxxxxxxx://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux