cpw.malu.ft_thumbnails: 7f22bfd9: Minor cleanup.
qulogic at pidgin.im
qulogic at pidgin.im
Sun Apr 25 17:50:45 EDT 2010
-----------------------------------------------------------------
Revision: 7f22bfd94afc3b9aef110b6726b20dabca323755
Ancestor: ca515c932ff67413763ed949adecbaae29aae7d5
Author: qulogic at pidgin.im
Date: 2010-04-25T20:38:17
Branch: im.pidgin.cpw.malu.ft_thumbnails
URL: http://d.pidgin.im/viewmtn/revision/info/7f22bfd94afc3b9aef110b6726b20dabca323755
Modified files:
libpurple/ft.c
ChangeLog:
Minor cleanup.
* g_free is NULL-safe.
* No need for an extra * on the gpointer.
* Adium doesn't like / in their <img> tags.
* purple_xfer_set_thumbnail should free previous data.
-------------- next part --------------
============================================================
--- libpurple/ft.c ba055680b55a4a14e77e52d6abca3f0a04ec4835
+++ libpurple/ft.c cbdb7c0b2a75f46d74dba380a7c0e1fd640ba71a
@@ -76,11 +76,9 @@ purple_xfer_priv_data_destroy(gpointer d
if (priv->buffer)
g_byte_array_free(priv->buffer, TRUE);
- if (priv->thumbnail_data)
- g_free(priv->thumbnail_data);
+ g_free(priv->thumbnail_data);
- if (priv->thumbnail_mimetype)
- g_free(priv->thumbnail_mimetype);
+ g_free(priv->thumbnail_mimetype);
g_free(priv);
}
@@ -283,7 +281,7 @@ purple_xfer_conversation_write_internal(
PurpleConversation *conv = NULL;
PurpleMessageFlags flags = PURPLE_MESSAGE_SYSTEM;
char *escaped;
- const gpointer *thumbnail_data = purple_xfer_get_thumbnail_data(xfer);
+ gconstpointer thumbnail_data = purple_xfer_get_thumbnail_data(xfer);
g_return_if_fail(xfer != NULL);
g_return_if_fail(message != NULL);
@@ -306,7 +304,7 @@ purple_xfer_conversation_write_internal(
int id = purple_imgstore_add_with_id(data, size, NULL);
message_with_img =
- g_strdup_printf("<img id='%d'/> %s", id, escaped);
+ g_strdup_printf("<img id='%d'> %s", id, escaped);
purple_conversation_write(conv, NULL, message_with_img, flags,
time(NULL));
purple_imgstore_unref_by_id(id);
@@ -324,7 +322,7 @@ purple_xfer_conversation_write(PurpleXfe
purple_xfer_conversation_write_internal(xfer, message, is_error, FALSE);
}
-/* maybe this one should be exported puplically? */
+/* maybe this one should be exported publically? */
static void
purple_xfer_conversation_write_with_thumbnail(PurpleXfer *xfer,
const gchar *message)
@@ -1662,10 +1660,17 @@ purple_xfer_set_thumbnail(PurpleXfer *xf
{
PurpleXferPrivData *priv = g_hash_table_lookup(xfers_data, xfer);
+ g_free(priv->thumbnail_data);
+ g_free(priv->thumbnail_mimetype);
+
if (thumbnail && size > 0) {
priv->thumbnail_data = g_memdup(thumbnail, size);
priv->thumbnail_size = size;
priv->thumbnail_mimetype = g_strdup(mimetype);
+ } else {
+ priv->thumbnail_data = NULL;
+ priv->thumbnail_size = 0;
+ priv->thumbnail_mimetype = NULL;
}
}
More information about the Commits
mailing list