changeset 23012:b0c9276bff93

Borrow a reference to a string instead of g_strdup'ing it. The PurpleStatus should ALWAYS be destroyed before the PurpleStatusType, so this should be ok. Yes, this is just one little string. But we copy every attribute for every PurpleStatus for every buddy on your buddylist--it adds up.
author Mark Doliner <mark@kingant.net>
date Tue, 20 May 2008 21:15:48 +0000
parents ba47ec8a2477
children e4f5a65d9a77
files libpurple/status.c
diffstat 1 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/status.c	Tue May 20 20:59:21 2008 +0000
+++ b/libpurple/status.c	Tue May 20 21:15:48 2008 +0000
@@ -111,6 +111,12 @@
 
 	gboolean active;
 
+	/*
+	 * The current values of the attributes for this status.  The
+	 * key is a string containing the name of the attribute.  It is
+	 * a borrowed reference from the list of attrs in the
+	 * PurpleStatusType.  The value is a PurpleValue.
+	 */
 	GHashTable *attr_values;
 };
 
@@ -563,7 +569,7 @@
 	status->presence = presence;
 
 	status->attr_values =
-		g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
+		g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
 		(GDestroyNotify)purple_value_destroy);
 
 	for (l = purple_status_type_get_attrs(status_type); l != NULL; l = l->next)
@@ -573,7 +579,7 @@
 		PurpleValue *new_value = purple_value_dup(value);
 
 		g_hash_table_insert(status->attr_values,
-							g_strdup(purple_status_attr_get_id(attr)),
+							(char *)purple_status_attr_get_id(attr),
 							new_value);
 	}