soc.2009.telepathy: 11bc32ee: Fixed some GValue related memory leaks

sttwister at gmail.com sttwister at gmail.com
Sat Sep 12 08:11:25 EDT 2009


-----------------------------------------------------------------
Revision: 11bc32ee5967bac0d2dc08a98398c4321f08de7d
Ancestor: c201d52fdd91712a40536ec93118b5ec21371500
Author: sttwister at gmail.com
Date: 2009-09-08T14:23:48
Branch: im.pidgin.soc.2009.telepathy
URL: http://d.pidgin.im/viewmtn/revision/info/11bc32ee5967bac0d2dc08a98398c4321f08de7d

Modified files:
        libpurple/protocols/telepathy/telepathy.c
        libpurple/protocols/telepathy/telepathy_utils.c

ChangeLog: 

Fixed some GValue related memory leaks

-------------- next part --------------
============================================================
--- libpurple/protocols/telepathy/telepathy.c	d990251f0de3f1e2020c465a31701026575bcf35
+++ libpurple/protocols/telepathy/telepathy.c	1b45212d18aee6e0ac2ca3099204adc67645c945
@@ -201,6 +201,9 @@ telepathy_login(PurpleAccount *acct)
 	PrplTpAccount *account_data = (PrplTpAccount*)purple_account_get_int(
 			acct, "tp_account_data", 0);
 
+	GValue *enabled;
+	GValue *requested_presence;
+
 	purple_debug_info("telepathy", "Connecting to account %s\n",
 			purple_account_get_username(acct));
 
@@ -211,21 +214,25 @@ telepathy_login(PurpleAccount *acct)
 		return;
 	}
 
-
 	initial_presence = purple_status_to_telepathy_status(
 		purple_account_get_active_status(acct));
 
+	enabled = tp_g_value_slice_new_boolean(TRUE);
+	requested_presence = tp_g_value_slice_new_boxed(G_TYPE_VALUE_ARRAY, initial_presence);
+
 	tp_cli_dbus_properties_call_set(account_data->tp_account, -1,
-		TP_IFACE_ACCOUNT, "Enabled", tp_g_value_slice_new_boolean(TRUE),
+		TP_IFACE_ACCOUNT, "Enabled", enabled,
 		NULL, NULL, NULL, NULL);
 
 	tp_cli_dbus_properties_call_set(account_data->tp_account, -1,
 		TP_IFACE_ACCOUNT, "RequestedPresence",
-		tp_g_value_slice_new_boxed(G_TYPE_VALUE_ARRAY, initial_presence),
+		requested_presence,
 		NULL, NULL, NULL, NULL);
 
 	g_value_array_free(initial_presence);
 
+	tp_g_value_slice_free(enabled);
+	tp_g_value_slice_free(requested_presence);
 }
 
 static void
@@ -236,6 +243,8 @@ telepathy_close(PurpleConnection *gc)
 	PrplTpAccount *account_data = (PrplTpAccount*)purple_account_get_int(
 			acct, "tp_account_data", 0);
 
+	GValue *enabled;
+
 	purple_debug_info("telepathy", "Disabling account %s\n",
 			purple_account_get_username(acct));
 
@@ -246,9 +255,13 @@ telepathy_close(PurpleConnection *gc)
 		return;
 	}
 
+	enabled = tp_g_value_slice_new_boolean(FALSE);
+
 	tp_cli_dbus_properties_call_set(account_data->tp_account, -1,
-		TP_IFACE_ACCOUNT, "Enabled", tp_g_value_slice_new_boolean(FALSE),
+		TP_IFACE_ACCOUNT, "Enabled", enabled,
 		NULL, NULL, NULL, NULL);
+
+	tp_g_value_slice_free(enabled);
 }
 
 static int
@@ -404,6 +417,7 @@ telepathy_set_status (PurpleAccount *acc
 			account, "tp_account_data", 0);
 
 	GValueArray *initial_presence;
+	GValue *requested_presence;
 
 	const gchar *presence_id = purple_status_get_id(status);
 	const gchar *presence_message = purple_status_get_attr_string(status, "message");
@@ -414,12 +428,16 @@ telepathy_set_status (PurpleAccount *acc
 	initial_presence = purple_status_to_telepathy_status(
 		purple_account_get_active_status(account));
 
+	requested_presence = tp_g_value_slice_new_boxed(G_TYPE_VALUE_ARRAY, initial_presence);
+
 	tp_cli_dbus_properties_call_set(account_data->tp_account, -1,
 		TP_IFACE_ACCOUNT, "RequestedPresence",
-		tp_g_value_slice_new_boxed(G_TYPE_VALUE_ARRAY, initial_presence),
+		requested_presence,
 		NULL, NULL, NULL, NULL);
 
 	g_value_array_free(initial_presence);
+
+	tp_g_value_slice_free(requested_presence);
 }
 
 static void
============================================================
--- libpurple/protocols/telepathy/telepathy_utils.c	85630e227f8b031be8c79fcbf09c5949ef2e40b7
+++ libpurple/protocols/telepathy/telepathy_utils.c	c9db188336ac3306f9d80edc43f3b2f0e3e3da74
@@ -36,14 +36,21 @@ purple_status_to_telepathy_status(Purple
 	const gchar *status_id = purple_status_get_id(status);
 	const gchar *presence_message = purple_status_get_attr_string(status, "message");
 
+	g_value_array_append(presence, NULL);
+	g_value_init(g_value_array_get_nth (presence, 0), G_TYPE_UINT);
 	if (purple_status_type_get_primitive(type) == PURPLE_STATUS_AVAILABLE)
-		g_value_array_append(presence, tp_g_value_slice_new_uint(2)); /* online */
+		g_value_set_uint(g_value_array_get_nth (presence, 0), 2);
 	else
-		g_value_array_append(presence, tp_g_value_slice_new_uint(1)); /* offline */
+		g_value_set_uint(g_value_array_get_nth (presence, 0), 1);
 
-	g_value_array_append(presence, tp_g_value_slice_new_string(status_id));
-	g_value_array_append(presence, tp_g_value_slice_new_string(presence_message));
+	g_value_array_append(presence, NULL);
+	g_value_init(g_value_array_get_nth (presence, 1), G_TYPE_STRING);
+	g_value_set_string(g_value_array_get_nth (presence, 1), status_id);
 
+	g_value_array_append(presence, NULL);
+	g_value_init(g_value_array_get_nth (presence, 2), G_TYPE_STRING);
+	g_value_set_string(g_value_array_get_nth (presence, 2), presence_message);
+
 	return presence;
 }
 


More information about the Commits mailing list