Mercurial > pidgin
comparison 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 |
comparison
equal
deleted
inserted
replaced
16805:04fecd1ee64d | 16806:10f175539cfe |
---|---|
370 { | 370 { |
371 PurpleConversation *conv; | 371 PurpleConversation *conv; |
372 PurpleAccount *account; | 372 PurpleAccount *account; |
373 const char *username; | 373 const char *username; |
374 PurpleBuddyIcon *icon_to_set; | 374 PurpleBuddyIcon *icon_to_set; |
375 GSList *sl, *list; | 375 GSList *buddies; |
376 | 376 |
377 g_return_if_fail(icon != NULL); | 377 g_return_if_fail(icon != NULL); |
378 | 378 |
379 account = purple_buddy_icon_get_account(icon); | 379 account = purple_buddy_icon_get_account(icon); |
380 username = purple_buddy_icon_get_username(icon); | 380 username = purple_buddy_icon_get_username(icon); |
384 * destroyed. The only way it wouldn't be destroyed is if someone | 384 * destroyed. The only way it wouldn't be destroyed is if someone |
385 * else is holding a reference to it, in which case they can kill | 385 * else is holding a reference to it, in which case they can kill |
386 * the icon when they realize it has no data. */ | 386 * the icon when they realize it has no data. */ |
387 icon_to_set = icon->img ? icon : NULL; | 387 icon_to_set = icon->img ? icon : NULL; |
388 | 388 |
389 for (list = sl = purple_find_buddies(account, username); | 389 buddies = purple_find_buddies(account, username); |
390 sl != NULL; | 390 while (buddies != NULL) |
391 sl = sl->next) | 391 { |
392 { | 392 PurpleBuddy *buddy = (PurpleBuddy *)buddies->data; |
393 PurpleBuddy *buddy = (PurpleBuddy *)sl->data; | |
394 char *old_icon; | 393 char *old_icon; |
395 | 394 |
396 purple_buddy_set_icon(buddy, icon_to_set); | 395 purple_buddy_set_icon(buddy, icon_to_set); |
397 | 396 |
398 | 397 |
423 purple_blist_node_remove_setting((PurpleBlistNode *)buddy, "buddy_icon"); | 422 purple_blist_node_remove_setting((PurpleBlistNode *)buddy, "buddy_icon"); |
424 purple_blist_node_remove_setting((PurpleBlistNode *)buddy, "icon_checksum"); | 423 purple_blist_node_remove_setting((PurpleBlistNode *)buddy, "icon_checksum"); |
425 } | 424 } |
426 unref_filename(old_icon); | 425 unref_filename(old_icon); |
427 g_free(old_icon); | 426 g_free(old_icon); |
428 } | 427 |
429 | 428 buddies = g_slist_delete_link(buddies, buddies); |
430 g_slist_free(list); | 429 } |
431 | 430 |
432 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, username, account); | 431 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, username, account); |
433 | 432 |
434 if (conv != NULL) | 433 if (conv != NULL) |
435 purple_conv_im_set_icon(PURPLE_CONV_IM(conv), icon_to_set); | 434 purple_conv_im_set_icon(PURPLE_CONV_IM(conv), icon_to_set); |