Mercurial > pidgin
diff libpurple/buddyicon.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 | 77cfd9bd6536 |
children | 56823a55581a 844ed0418744 |
line wrap: on
line diff
--- a/libpurple/buddyicon.c Thu May 03 07:51:51 2007 +0000 +++ b/libpurple/buddyicon.c Thu May 03 07:55:32 2007 +0000 @@ -372,7 +372,7 @@ PurpleAccount *account; const char *username; PurpleBuddyIcon *icon_to_set; - GSList *sl, *list; + GSList *buddies; g_return_if_fail(icon != NULL); @@ -386,11 +386,10 @@ * the icon when they realize it has no data. */ icon_to_set = icon->img ? icon : NULL; - for (list = sl = purple_find_buddies(account, username); - sl != NULL; - sl = sl->next) + buddies = purple_find_buddies(account, username); + while (buddies != NULL) { - PurpleBuddy *buddy = (PurpleBuddy *)sl->data; + PurpleBuddy *buddy = (PurpleBuddy *)buddies->data; char *old_icon; purple_buddy_set_icon(buddy, icon_to_set); @@ -425,10 +424,10 @@ } unref_filename(old_icon); g_free(old_icon); + + buddies = g_slist_delete_link(buddies, buddies); } - g_slist_free(list); - conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, username, account); if (conv != NULL)