comparison libpurple/connection.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 4999bbc52881
children 44393d3e0c3b f2d8658b3a86
comparison
equal deleted inserted replaced
16816:04fecd1ee64d 16817:10f175539cfe
159 159
160 void 160 void
161 purple_connection_destroy(PurpleConnection *gc) 161 purple_connection_destroy(PurpleConnection *gc)
162 { 162 {
163 PurpleAccount *account; 163 PurpleAccount *account;
164 GSList *buddies, *tmp; 164 GSList *buddies;
165 #if 0 165 #if 0
166 GList *wins; 166 GList *wins;
167 #endif 167 #endif
168 PurplePluginProtocolInfo *prpl_info = NULL; 168 PurplePluginProtocolInfo *prpl_info = NULL;
169 gboolean remove = FALSE; 169 gboolean remove = FALSE;
195 if (prpl_info->close) 195 if (prpl_info->close)
196 (prpl_info->close)(gc); 196 (prpl_info->close)(gc);
197 197
198 /* Clear out the proto data that was freed in the prpl close method*/ 198 /* Clear out the proto data that was freed in the prpl close method*/
199 buddies = purple_find_buddies(account, NULL); 199 buddies = purple_find_buddies(account, NULL);
200 for (tmp = buddies; tmp; tmp = tmp->next) { 200 while (buddies != NULL) {
201 PurpleBuddy *buddy = tmp->data; 201 PurpleBuddy *buddy = buddies->data;
202 buddy->proto_data = NULL; 202 buddy->proto_data = NULL;
203 } 203 buddies = g_slist_delete_link(buddies, buddies);
204 g_slist_free(buddies); 204 }
205 205
206 connections = g_list_remove(connections, gc); 206 connections = g_list_remove(connections, gc);
207 207
208 purple_connection_set_state(gc, PURPLE_DISCONNECTED); 208 purple_connection_set_state(gc, PURPLE_DISCONNECTED);
209 209