Mercurial > pidgin
comparison src/prpl.c @ 12126:35c4797c5c57
[gaim-migrate @ 14426]
SF Patch #1359761, from sadrul
"This patch plugs some memory leaks in a few places
ragarding gaim_find_buddies. It also changes the call
to gaim_find_buddy in a couple of places that only
needs one buddy."
I also fixed a case of g_free()ing a const char * in the sametime prpl.
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Fri, 18 Nov 2005 12:05:40 +0000 |
parents | 1d4fbf553ce2 |
children | 6f41d8d33989 |
comparison
equal
deleted
inserted
replaced
12125:3c1bac709234 | 12126:35c4797c5c57 |
---|---|
186 | 186 |
187 void | 187 void |
188 gaim_prpl_got_user_idle(GaimAccount *account, const char *name, | 188 gaim_prpl_got_user_idle(GaimAccount *account, const char *name, |
189 gboolean idle, time_t idle_time) | 189 gboolean idle, time_t idle_time) |
190 { | 190 { |
191 GSList *l; | 191 GSList *list, *iter; |
192 | 192 |
193 g_return_if_fail(account != NULL); | 193 g_return_if_fail(account != NULL); |
194 g_return_if_fail(name != NULL); | 194 g_return_if_fail(name != NULL); |
195 g_return_if_fail(gaim_account_is_connected(account)); | 195 g_return_if_fail(gaim_account_is_connected(account)); |
196 | 196 |
197 for (l = gaim_find_buddies(account, name); l != NULL; l = l->next) | 197 list = gaim_find_buddies(account, name); |
198 for (iter = list; iter != NULL; iter = iter->next) | |
198 { | 199 { |
199 GaimBuddy *buddy; | 200 GaimBuddy *buddy; |
200 GaimPresence *presence; | 201 GaimPresence *presence; |
201 | 202 |
202 buddy = (GaimBuddy *)l->data; | 203 buddy = (GaimBuddy *)iter->data; |
203 | 204 |
204 presence = gaim_buddy_get_presence(buddy); | 205 presence = gaim_buddy_get_presence(buddy); |
205 | 206 |
206 gaim_presence_set_idle(presence, idle, idle_time); | 207 gaim_presence_set_idle(presence, idle, idle_time); |
207 } | 208 } |
209 g_slist_free(list); | |
208 } | 210 } |
209 | 211 |
210 void | 212 void |
211 gaim_prpl_got_user_login_time(GaimAccount *account, const char *name, | 213 gaim_prpl_got_user_login_time(GaimAccount *account, const char *name, |
212 time_t login_time) | 214 time_t login_time) |
213 { | 215 { |
214 GSList *l; | 216 GSList *list, *iter; |
215 | 217 |
216 g_return_if_fail(account != NULL); | 218 g_return_if_fail(account != NULL); |
217 g_return_if_fail(name != NULL); | 219 g_return_if_fail(name != NULL); |
218 | 220 |
219 for (l = gaim_find_buddies(account, name); l != NULL; l = l->next) | 221 list = gaim_find_buddies(account, name); |
222 for (iter = list; iter != NULL; iter = iter->next) | |
220 { | 223 { |
221 GaimBuddy *buddy; | 224 GaimBuddy *buddy; |
222 GaimPresence *presence; | 225 GaimPresence *presence; |
223 | 226 |
224 buddy = (GaimBuddy *)l->data; | 227 buddy = (GaimBuddy *)iter->data; |
225 | 228 |
226 if (login_time == 0) | 229 if (login_time == 0) |
227 login_time = time(NULL); | 230 login_time = time(NULL); |
228 | 231 |
229 presence = gaim_buddy_get_presence(buddy); | 232 presence = gaim_buddy_get_presence(buddy); |
230 | 233 |
231 gaim_presence_set_login_time(presence, login_time); | 234 gaim_presence_set_login_time(presence, login_time); |
232 } | 235 } |
236 g_slist_free(list); | |
233 } | 237 } |
234 | 238 |
235 void | 239 void |
236 gaim_prpl_got_user_status(GaimAccount *account, const char *name, | 240 gaim_prpl_got_user_status(GaimAccount *account, const char *name, |
237 const char *status_id, const char *attr_id, ...) | 241 const char *status_id, const char *attr_id, ...) |
238 { | 242 { |
239 GSList *l; | 243 GSList *list, *iter; |
240 | 244 |
241 g_return_if_fail(account != NULL); | 245 g_return_if_fail(account != NULL); |
242 g_return_if_fail(name != NULL); | 246 g_return_if_fail(name != NULL); |
243 g_return_if_fail(status_id != NULL); | 247 g_return_if_fail(status_id != NULL); |
244 g_return_if_fail(gaim_account_is_connected(account)); | 248 g_return_if_fail(gaim_account_is_connected(account)); |
245 | 249 |
246 for (l = gaim_find_buddies(account, name); l != NULL; l = l->next) | 250 list = gaim_find_buddies(account, name); |
251 for (iter = list; iter != NULL; iter = iter->next) | |
247 { | 252 { |
248 GaimBuddy *buddy; | 253 GaimBuddy *buddy; |
249 GaimPresence *presence; | 254 GaimPresence *presence; |
250 GaimStatus *status; | 255 GaimStatus *status; |
251 GaimStatus *old_status; | 256 GaimStatus *old_status; |
252 | 257 |
253 buddy = (GaimBuddy *)l->data; | 258 buddy = (GaimBuddy *)iter->data; |
254 presence = gaim_buddy_get_presence(buddy); | 259 presence = gaim_buddy_get_presence(buddy); |
255 status = gaim_presence_get_status(presence, status_id); | 260 status = gaim_presence_get_status(presence, status_id); |
256 | 261 |
257 g_return_if_fail(status != NULL); | 262 g_return_if_fail(status != NULL); |
258 | 263 |
274 | 279 |
275 old_status = gaim_presence_get_active_status(presence); | 280 old_status = gaim_presence_get_active_status(presence); |
276 gaim_presence_set_status_active(presence, status_id, TRUE); | 281 gaim_presence_set_status_active(presence, status_id, TRUE); |
277 gaim_blist_update_buddy_status(buddy, old_status); | 282 gaim_blist_update_buddy_status(buddy, old_status); |
278 } | 283 } |
284 g_slist_free(list); | |
279 } | 285 } |
280 | 286 |
281 void | 287 void |
282 gaim_prpl_change_account_status(GaimAccount *account, | 288 gaim_prpl_change_account_status(GaimAccount *account, |
283 GaimStatus *old_status, GaimStatus *new_status) | 289 GaimStatus *old_status, GaimStatus *new_status) |