Mercurial > pidgin
diff libpurple/server.c @ 16806:10f175539cfe
Change a few functions to free a linked list while iterating through
it instead of after iterating through it. This is probably a very
tiny bit faster, but more importantly, I think the code is easier to
read
| author | Mark Doliner <mark@kingant.net> |
|---|---|
| date | Thu, 03 May 2007 07:55:32 +0000 |
| parents | 964078401036 |
| children | bfdd46b72027 |
line wrap: on
line diff
--- a/libpurple/server.c Thu May 03 07:51:51 2007 +0000 +++ b/libpurple/server.c Thu May 03 07:55:32 2007 +0000 @@ -210,22 +210,24 @@ serv_got_alias(PurpleConnection *gc, const char *who, const char *alias) { PurpleAccount *account = purple_connection_get_account(gc); - GSList *buds, *buddies = purple_find_buddies(account, who); + GSList *buddies = purple_find_buddies(account, who); PurpleBuddy *b; PurpleConversation *conv; - for (buds = buddies; buds; buds = buds->next) + while (buddies != NULL) { - b = buds->data; + b = buddies->data; + buddies = g_slist_delete_link(buddies, buddies); + if ((b->server_alias == NULL && alias == NULL) || (b->server_alias && alias && !strcmp(b->server_alias, alias))) { continue; } + purple_blist_server_alias_buddy(b, alias); conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, b->name, account); - if (conv != NULL && alias != NULL && strcmp(alias, who)) { char *tmp = g_strdup_printf(_("%s is now known as %s.\n"), @@ -237,7 +239,6 @@ g_free(tmp); } } - g_slist_free(buddies); } /*
