Mercurial > pidgin.yaz
diff libpurple/privacy.c @ 16817: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 | 32c366eeeb99 |
children | 44b4e8bd759b |
line wrap: on
line diff
--- a/libpurple/privacy.c Thu May 03 07:51:51 2007 +0000 +++ b/libpurple/privacy.c Thu May 03 07:55:32 2007 +0000 @@ -206,7 +206,8 @@ static void add_buddies_in_permit(PurpleAccount *account, gboolean local) { - GSList *list, *iter; + GSList *list; + /* Remove anyone in the permit list who is not in the buddylist */ for (list = account->permit; list != NULL; ) { char *person = list->data; @@ -214,13 +215,16 @@ if (!purple_find_buddy(account, person)) purple_privacy_permit_remove(account, person, local); } + /* Now make sure everyone in the buddylist is in the permit list */ - for (iter = list = purple_find_buddies(account, NULL); iter; iter = iter->next) { - PurpleBuddy *buddy = iter->data; + list = purple_find_buddies(account, NULL); + while (list != NULL) + { + PurpleBuddy *buddy = list->data; if (!g_slist_find_custom(account->permit, buddy->name, (GCompareFunc)g_utf8_collate)) purple_privacy_permit_add(account, buddy->name, local); + list = g_slist_delete_link(list, list); } - g_slist_free(list); } void