pidgin: 73ff5eb4: Borrow a reference to a string instead o...

markdoliner at pidgin.im markdoliner at pidgin.im
Tue May 20 17:21:10 EDT 2008


-----------------------------------------------------------------
Revision: 73ff5eb429127d9a89484809ba81b50b6ed5c200
Ancestor: 38a143a948abbbfeb8fc6623161a3dc177469484
Author: markdoliner at pidgin.im
Date: 2008-05-20T21:15:48
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/73ff5eb429127d9a89484809ba81b50b6ed5c200

Modified files:
        libpurple/status.c

ChangeLog: 

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.

-------------- next part --------------
============================================================
--- libpurple/status.c	d5fad32197a4b3d45edee4cc864f9912f43b0e1a
+++ libpurple/status.c	25a57059f1557a35cfcafb10e16edc7006e85b91
@@ -111,6 +111,12 @@ struct _PurpleStatus
 
 	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 @@ purple_status_new(PurpleStatusType *stat
 	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 @@ purple_status_new(PurpleStatusType *stat
 		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);
 	}
 


More information about the Commits mailing list