changeset 17669:d727fda5a8e1

Change around msim_uid2username_from_blist() to try to get it to work (based on finch/gnthistory.c's looping over the buddy list), but leave it commented out because it still causes the crash in msim_parse().
author Jeffrey Connelly <jaconnel@calpoly.edu>
date Tue, 26 Jun 2007 05:33:00 +0000
parents a014bcce5a5d
children 7e4e3f6582d2
files libpurple/protocols/myspace/myspace.c
diffstat 1 files changed, 31 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/myspace/myspace.c	Tue Jun 26 05:16:29 2007 +0000
+++ b/libpurple/protocols/myspace/myspace.c	Tue Jun 26 05:33:00 2007 +0000
@@ -1250,7 +1250,7 @@
 	g_hash_table_destroy(body);
 }
 
-#ifdef _MSIM_UID2USERNAME_WORKS
+#if 0
 /* Lookup a username by userid, from buddy list. 
  *
  * @param wanted_uid
@@ -1262,19 +1262,30 @@
 static const gchar *
 msim_uid2username_from_blist(MsimSession *session, guint wanted_uid)
 {
-	GSList *buddies, *buddies_head;
-
-	for (buddies = buddies_head = purple_find_buddies(session->account, NULL); 
-			buddies; 
-			buddies = g_slist_next(buddies))
+	GSList *buddies, *cur;
+
+	buddies = purple_find_buddies(session->account, NULL); 
+
+	if (!buddies)
+	{
+		purple_debug_info("msim", "msim_uid2username_from_blist: no buddies?");
+		return NULL;
+	}
+
+	for (cur = buddies; cur != NULL; cur = g_slist_next(cur))
 	{
 		PurpleBuddy *buddy;
+		//PurpleBlistNode *node;
 		guint uid;
-		gchar *name;
-
-		buddy = buddies->data;
+		const gchar *name;
+
+
+		/* See finch/gnthistory.c */
+		buddy = cur->data;
+		//node  = cur->data;
 
 		uid = purple_blist_node_get_int(&buddy->node, "UserID");
+		//uid = purple_blist_node_get_int(node, "UserID");
 
 		/* name = buddy->name; */								/* crash */
 		/* name = PURPLE_BLIST_NODE_NAME(&buddy->node);  */		/* crash */
@@ -1282,6 +1293,7 @@
 		/* XXX Is this right? Memory corruption here somehow. Happens only
 		 * when return one of these values. */
 		name = purple_buddy_get_name(buddy); 					/* crash */
+		//name = purple_buddy_get_name((PurpleBuddy *)node); 	/* crash */
 		/* return name; */										/* crash (with above) */
 
 		/* name = NULL; */										/* no crash */
@@ -1323,23 +1335,24 @@
 
 	Why is it crashing in msim_parse()'s g_strdup()?
 */
-
-
 		purple_debug_info("msim", "msim_uid2username_from_blist: %s's uid=%d (want %d)\n",
 				name, uid, wanted_uid);
 
 		if (uid == wanted_uid)
 		{
-			g_slist_free(buddies_head);
-
-			return name;
+			gchar *ret;
+
+			ret = g_strdup(name);
+
+			g_slist_free(buddies);
+
+			return ret;
 		}
 	}
 
-	g_slist_free(buddies_head);
+	g_slist_free(buddies);
 	return NULL;
 }
-
 #endif
 
 /** Preprocess incoming messages, resolving as needed, calling msim_process() when ready to process.
@@ -1360,11 +1373,10 @@
 
 		/* TODO: Make caching work. Currently it is commented out because
 		 * it crashes for unknown reasons, memory realloc error. */
-//#define _MSIM_UID2USERNAME_WORKS
-#ifdef _MSIM_UID2USERNAME_WORKS
+#if 0
 		username = msim_uid2username_from_blist(session, uid); 
 #else
-		username = NULL;
+		username = NULL; 
 #endif
 
 		if (username)