cpw.darkrain42.xmpp.bosh: 5a69e76f: Partial disapproval of b8fdbd255c614e730...

paul at darkrain42.org paul at darkrain42.org
Sat Jan 17 23:56:01 EST 2009


-----------------------------------------------------------------
Revision: 5a69e76fa709eb4d74b61616910a3205a3935869
Ancestor: 5c946b904cc1a855be2fc7b82f70a67d66204570
Author: paul at darkrain42.org
Date: 2008-12-19T04:28:38
Branch: im.pidgin.cpw.darkrain42.xmpp.bosh
URL: http://d.pidgin.im/viewmtn/revision/info/5a69e76fa709eb4d74b61616910a3205a3935869

Modified files:
        libpurple/protocols/jabber/buddy.c
        libpurple/protocols/jabber/caps.c
        libpurple/protocols/jabber/caps.h
        libpurple/protocols/jabber/presence.c

ChangeLog: 

Partial disapproval of b8fdbd255c614e7305f835b843a3414675a86a19

Don't refcount the Client Info struct. It's always owned by the capstable
and will be freed via jabber_caps_uninit().

-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/buddy.c	4d0c7897c82d10209bfa260624e042ceacce7e42
+++ libpurple/protocols/jabber/buddy.c	e657c248489175a169e26f5e4a6f6663ab9bdeb3
@@ -181,7 +181,6 @@ void jabber_buddy_resource_free(JabberBu
 		jbr->commands = g_list_delete_link(jbr->commands, jbr->commands);
 	}
 
-	jabber_caps_client_info_unref(jbr->caps.info);
 	if (jbr->caps.exts) {
 		g_list_foreach(jbr->caps.exts, (GFunc)g_free, NULL);
 		g_list_free(jbr->caps.exts);
============================================================
--- libpurple/protocols/jabber/caps.c	66b1225a2da9d443014d0c919b8e2ccd8c4004d4
+++ libpurple/protocols/jabber/caps.c	a95e5767d989013e75486f5a33f18d3dac8dd3bf
@@ -116,25 +116,12 @@ void jabber_caps_destroy_key(gpointer da
 	g_free(key);
 }
 
-JabberCapsClientInfo *
-jabber_caps_client_info_ref(JabberCapsClientInfo *info)
+static void
+jabber_caps_client_info_destroy(JabberCapsClientInfo *info)
 {
-	g_return_val_if_fail(info != NULL, NULL);
-	++info->ref;
-	return info;
-}
-
-void
-jabber_caps_client_info_unref(JabberCapsClientInfo *info)
-{
 	if (info == NULL)
 		return;
 
-	g_return_if_fail(info->ref != 0);
-
-	if (--info->ref != 0)
-		return;
-
 	while(info->identities) {
 		JabberIdentity *id = info->identities->data;
 		g_free(id->category);
@@ -269,7 +256,6 @@ jabber_caps_load(void)
 			JabberCapsClientInfo *value = g_new0(JabberCapsClientInfo, 1);
 			xmlnode *child;
 			JabberCapsNodeExts *exts = NULL;
-			jabber_caps_client_info_ref(value);
 			key->node = g_strdup(xmlnode_get_attrib(client,"node"));
 			key->ver  = g_strdup(xmlnode_get_attrib(client,"ver"));
 			key->hash = g_strdup(xmlnode_get_attrib(client,"hash"));
@@ -351,7 +337,7 @@ void jabber_caps_init(void)
 void jabber_caps_init(void)
 {
 	nodetable = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify)jabber_caps_node_exts_unref); 
-	capstable = g_hash_table_new_full(jabber_caps_hash, jabber_caps_compare, jabber_caps_destroy_key, (GDestroyNotify)jabber_caps_client_info_unref);
+	capstable = g_hash_table_new_full(jabber_caps_hash, jabber_caps_compare, jabber_caps_destroy_key, (GDestroyNotify)jabber_caps_client_info_destroy);
 	jabber_caps_load();
 }
 
@@ -410,8 +396,7 @@ cbplususerdata_unref(jabber_caps_cbplusu
 	g_free(data->ver);
 	g_free(data->hash);
 
-	if (data->info)
-		jabber_caps_client_info_unref(data->info);
+	/* If we have info here, it's already in the capstable, so don't free it */
 	if (data->exts)
 		free_string_glist(data->exts);
 	if (data->node_exts)
@@ -465,7 +450,7 @@ jabber_caps_client_iqcb(JabberStream *js
 			                     xmlnode_get_attrib(packet, "from"));
 
 			userdata->cb(NULL, NULL, userdata->cb_data);
-			jabber_caps_client_info_unref(info);
+			jabber_caps_client_info_destroy(info);
 			cbplususerdata_unref(userdata);
 			g_free(hash);
 			return;
@@ -481,8 +466,6 @@ jabber_caps_client_iqcb(JabberStream *js
 		userdata->node_exts = NULL;
 	}
 
-	userdata->info = info;
-
 	key.node = userdata->node;
 	key.ver  = userdata->ver;
 	key.hash = userdata->hash;
@@ -490,8 +473,7 @@ jabber_caps_client_iqcb(JabberStream *js
 	/* Use the copy of this data already in the table if it exists or insert
 	 * a new one if we need to */
 	if ((value = g_hash_table_lookup(capstable, &key))) {
-		jabber_caps_client_info_unref(info);
-		jabber_caps_client_info_ref(value);
+		jabber_caps_client_info_destroy(info);
 		info = value;
 	} else {
 		JabberCapsKey *n_key = g_new(JabberCapsKey, 1);
@@ -501,10 +483,12 @@ jabber_caps_client_iqcb(JabberStream *js
 		userdata->node = userdata->ver = userdata->hash = NULL;
 
 		/* The capstable gets a reference */
-		g_hash_table_insert(capstable, n_key, jabber_caps_client_info_ref(info));
+		g_hash_table_insert(capstable, n_key, info);
 		schedule_caps_save();
 	}
 
+	userdata->info = info;
+
 	if (userdata->extOutstanding == 0)
 		jabber_caps_get_info_complete(userdata);
 
@@ -579,7 +563,7 @@ void jabber_caps_get_info(JabberStream *
 	info = g_hash_table_lookup(capstable, &key);
 	if (info && hash) {
 		/* v1.5 - We already have all the information we care about */
-		cb(jabber_caps_client_info_ref(info), NULL, user_data);
+		cb(info, NULL, user_data);
 		return;
 	}
 
@@ -595,7 +579,7 @@ void jabber_caps_get_info(JabberStream *
 	userdata->hash = g_strdup(hash);
 
 	if (info) {
-		userdata->info = jabber_caps_client_info_ref(info);
+		userdata->info = info;
 	} else {
 		/* If we don't have the basic information about the client, we need
 		 * to fetch it. */
@@ -735,7 +719,6 @@ static JabberCapsClientInfo *jabber_caps
 		return 0;
 	
 	info = g_new0(JabberCapsClientInfo, 1);
-	jabber_caps_client_info_ref(info);
 
 	for(child = query->child; child; child = child->next) {
 		if (!strcmp(child->name,"identity")) {
============================================================
--- libpurple/protocols/jabber/caps.h	395e5fe80ead45433f13ca16946ebe6ddb8cda7d
+++ libpurple/protocols/jabber/caps.h	09ccd309f977e1c202a1b8c62fdd31a70200ed93
@@ -35,7 +35,6 @@ struct _JabberCapsClientInfo {
 	GList *features; /* char * */
 	GList *forms; /* xmlnode * */
 	JabberCapsNodeExts *exts;
-	guint ref;
 };
 
 /*
@@ -56,14 +55,6 @@ struct _JabberCapsNodeExts {
 	GHashTable *exts; /* char *ext_name -> GList *features */
 };
 
-/**
- * Adjust the refcount for JabberCapsClientInfo. When the refcount reaches
- * 0, the data will be destroyed.
- */
-void jabber_caps_client_info_unref(JabberCapsClientInfo *info);
-JabberCapsClientInfo* jabber_caps_client_info_ref(JabberCapsClientInfo *info);
-
-
 typedef void (*jabber_caps_get_info_cb)(JabberCapsClientInfo *info, GList *exts, gpointer user_data);
 
 void jabber_caps_init(void);
============================================================
--- libpurple/protocols/jabber/presence.c	6c064fcf8285b104ee1223b6652edcd71efe509a
+++ libpurple/protocols/jabber/presence.c	fd30ea8c9601f4343cfcd1a176418f7de52b3813
@@ -394,7 +394,6 @@ jabber_presence_set_capabilities(JabberC
 	if (!jbr) {
 		g_free(userdata->from);
 		g_free(userdata);
-		jabber_caps_client_info_unref(info);
 		if (exts) {
 			g_list_foreach(exts, (GFunc)g_free, NULL);
 			g_list_free(exts);
@@ -402,7 +401,7 @@ jabber_presence_set_capabilities(JabberC
 		return;
 	}
 
-	jabber_caps_client_info_unref(jbr->caps.info);
+	/* Any old jbr->caps.info is owned by the caps code */
 	if (jbr->caps.exts) {
 		g_list_foreach(jbr->caps.exts, (GFunc)g_free, NULL);
 		g_list_free(jbr->caps.exts);


More information about the Commits mailing list