diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2011-05-26 17:10:06 +0800 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2011-06-01 17:58:09 +0800 |
commit | 7625bd2ae11f2c3064e3e208ea82fffa97dc7f18 (patch) | |
tree | a712a30e71d5f2fd97f4047a35f8078f5b4ecb9e /libempathy-gtk/empathy-avatar-chooser.c | |
parent | ba731f3dceb447ffe8c4b9e168ad1c1a5f99f365 (diff) | |
download | gsoc2013-empathy-7625bd2ae11f2c3064e3e208ea82fffa97dc7f18.tar gsoc2013-empathy-7625bd2ae11f2c3064e3e208ea82fffa97dc7f18.tar.gz gsoc2013-empathy-7625bd2ae11f2c3064e3e208ea82fffa97dc7f18.tar.bz2 gsoc2013-empathy-7625bd2ae11f2c3064e3e208ea82fffa97dc7f18.tar.lz gsoc2013-empathy-7625bd2ae11f2c3064e3e208ea82fffa97dc7f18.tar.xz gsoc2013-empathy-7625bd2ae11f2c3064e3e208ea82fffa97dc7f18.tar.zst gsoc2013-empathy-7625bd2ae11f2c3064e3e208ea82fffa97dc7f18.zip |
empathy_avatar_new: stop stealing strings (#650939)
It was pretty confusing when reading/reviewing code.
Diffstat (limited to 'libempathy-gtk/empathy-avatar-chooser.c')
-rw-r--r-- | libempathy-gtk/empathy-avatar-chooser.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/libempathy-gtk/empathy-avatar-chooser.c b/libempathy-gtk/empathy-avatar-chooser.c index ff2785908..2d1c59943 100644 --- a/libempathy-gtk/empathy-avatar-chooser.c +++ b/libempathy-gtk/empathy-avatar-chooser.c @@ -607,10 +607,12 @@ avatar_chooser_maybe_convert_and_scale (EmpathyAvatarChooser *self, g_free (new_format_name); - /* Takes ownership of new_mime_type and best_image_data */ avatar = empathy_avatar_new ((guchar *) best_image_data, best_image_size, new_mime_type, NULL); + g_free (best_image_data); + g_free (new_mime_type); + return avatar; } @@ -655,6 +657,7 @@ avatar_chooser_set_image (EmpathyAvatarChooser *self, g_object_unref (pixbuf); } +/* takes ownership of @data */ static void avatar_chooser_set_image_from_data (EmpathyAvatarChooser *self, gchar *data, @@ -679,10 +682,12 @@ avatar_chooser_set_image_from_data (EmpathyAvatarChooser *self, return; } - /* avatar takes ownership of data and mime_type */ avatar = empathy_avatar_new ((guchar *) data, size, mime_type, NULL); avatar_chooser_set_image (self, avatar, pixbuf, set_locally); + + g_free (mime_type); + g_free (data); } static void @@ -730,12 +735,8 @@ avatar_chooser_drag_data_received_cb (GtkWidget *widget, if (handled) { - /* this in turn calls empathy_avatar_new (), which assumes - * ownership of data. - */ - avatar_chooser_set_image_from_data (self, data, - bytes_read, - TRUE); + /* pass data to the avatar_chooser_set_image_from_data */ + avatar_chooser_set_image_from_data (self, data, bytes_read, TRUE); } g_object_unref (file); @@ -801,6 +802,7 @@ avatar_chooser_set_image_from_file (EmpathyAvatarChooser *self, return; } + /* pass image_data to the avatar_chooser_set_image_from_data */ avatar_chooser_set_image_from_data (self, image_data, image_size, TRUE); } @@ -809,8 +811,6 @@ static void avatar_chooser_set_avatar_from_pixbuf (EmpathyAvatarChooser *self, GdkPixbuf *pb) { - /* dup the string as empathy_avatar_new steals ownership of the it */ - gchar *mime = g_strdup ("image/png"); gsize size; gchar *buf; EmpathyAvatar *avatar = NULL; @@ -825,8 +825,10 @@ avatar_chooser_set_avatar_from_pixbuf (EmpathyAvatarChooser *self, return; } - avatar = empathy_avatar_new ((guchar *) buf, size, mime, NULL); + avatar = empathy_avatar_new ((guchar *) buf, size, "image/png", NULL); avatar_chooser_set_image (self, avatar, pb, TRUE); + + g_free (buf); } static gboolean |