Mercurial > pidgin
changeset 25191:5ad14a53e266
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().
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Fri, 19 Dec 2008 04:28:38 +0000 |
parents | 3bec4f4db198 |
children | 592c2cf00fea |
files | libpurple/protocols/jabber/buddy.c libpurple/protocols/jabber/caps.c libpurple/protocols/jabber/caps.h libpurple/protocols/jabber/presence.c |
diffstat | 4 files changed, 12 insertions(+), 40 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/jabber/buddy.c Fri Dec 19 04:18:42 2008 +0000 +++ b/libpurple/protocols/jabber/buddy.c Fri Dec 19 04:28:38 2008 +0000 @@ -181,7 +181,6 @@ 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);
--- a/libpurple/protocols/jabber/caps.c Fri Dec 19 04:18:42 2008 +0000 +++ b/libpurple/protocols/jabber/caps.c Fri Dec 19 04:28:38 2008 +0000 @@ -116,25 +116,12 @@ g_free(key); } -JabberCapsClientInfo * -jabber_caps_client_info_ref(JabberCapsClientInfo *info) -{ - g_return_val_if_fail(info != NULL, NULL); - ++info->ref; - return info; -} - -void -jabber_caps_client_info_unref(JabberCapsClientInfo *info) +static void +jabber_caps_client_info_destroy(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 @@ 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) { 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 @@ 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 @@ 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 @@ userdata->node_exts = NULL; } - userdata->info = info; - key.node = userdata->node; key.ver = userdata->ver; key.hash = userdata->hash; @@ -490,8 +473,7 @@ /* 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 @@ 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 @@ 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 @@ 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 @@ 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")) {
--- a/libpurple/protocols/jabber/caps.h Fri Dec 19 04:18:42 2008 +0000 +++ b/libpurple/protocols/jabber/caps.h Fri Dec 19 04:28:38 2008 +0000 @@ -35,7 +35,6 @@ GList *features; /* char * */ GList *forms; /* xmlnode * */ JabberCapsNodeExts *exts; - guint ref; }; /* @@ -56,14 +55,6 @@ 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);
--- a/libpurple/protocols/jabber/presence.c Fri Dec 19 04:18:42 2008 +0000 +++ b/libpurple/protocols/jabber/presence.c Fri Dec 19 04:28:38 2008 +0000 @@ -394,7 +394,6 @@ 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 @@ 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);