# HG changeset patch # User Jeffrey Connelly # Date 1182835980 0 # Node ID d727fda5a8e127d859cec3b6799f3aad3dee8aa1 # Parent a014bcce5a5da5068710ece1be5a9a12831d09da 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(). diff -r a014bcce5a5d -r d727fda5a8e1 libpurple/protocols/myspace/myspace.c --- 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)