Mercurial > pidgin
comparison libpurple/protocols/jabber/jingle.c @ 23852:a1a1f44cdecc
Fixed some memory leak issues involving GLists.
author | Mike Ruprecht <maiku@soc.pidgin.im> |
---|---|
date | Fri, 11 Jul 2008 02:10:04 +0000 |
parents | 84c7bb2ca41f |
children | 1c68f78414b7 |
comparison
equal
deleted
inserted
replaced
23851:5736b1881bf4 | 23852:a1a1f44cdecc |
---|---|
248 } | 248 } |
249 | 249 |
250 static void | 250 static void |
251 jabber_jingle_session_destroy(JingleSession *sess) | 251 jabber_jingle_session_destroy(JingleSession *sess) |
252 { | 252 { |
253 GList *contents = g_hash_table_get_values(sess->contents); | 253 GList *contents; |
254 g_hash_table_remove(sess->js->sessions, sess->id); | 254 g_hash_table_remove(sess->js->sessions, sess->id); |
255 g_free(sess->id); | 255 g_free(sess->id); |
256 | 256 |
257 if (sess->media) | 257 if (sess->media) |
258 g_object_unref(sess->media); | 258 g_object_unref(sess->media); |
259 | 259 |
260 for (; contents; contents = contents->next) | 260 for (contents = g_hash_table_get_values(sess->contents); contents; |
261 contents = g_list_delete_link(contents, contents)) | |
261 jabber_jingle_session_destroy_content(contents->data); | 262 jabber_jingle_session_destroy_content(contents->data); |
262 | 263 |
263 g_list_free(contents); | |
264 g_free(sess); | 264 g_free(sess); |
265 } | 265 } |
266 | 266 |
267 static JingleSession * | 267 static JingleSession * |
268 jabber_jingle_session_find_by_id(JabberStream *js, const char *id) | 268 jabber_jingle_session_find_by_id(JabberStream *js, const char *id) |
276 | 276 |
277 static JingleSession * | 277 static JingleSession * |
278 jabber_jingle_session_find_by_jid(JabberStream *js, const char *jid) | 278 jabber_jingle_session_find_by_jid(JabberStream *js, const char *jid) |
279 { | 279 { |
280 GList *values = g_hash_table_get_values(js->sessions); | 280 GList *values = g_hash_table_get_values(js->sessions); |
281 GList *iter = values; | |
282 gboolean use_bare = strchr(jid, '/') == NULL; | 281 gboolean use_bare = strchr(jid, '/') == NULL; |
283 | 282 |
284 for (; iter; iter = iter->next) { | 283 for (; values; values = g_list_delete_link(values, values)) { |
285 JingleSession *session = (JingleSession *)iter->data; | 284 JingleSession *session = (JingleSession *)values->data; |
286 gchar *cmp_jid = use_bare ? jabber_get_bare_jid(session->remote_jid) | 285 gchar *cmp_jid = use_bare ? jabber_get_bare_jid(session->remote_jid) |
287 : g_strdup(session->remote_jid); | 286 : g_strdup(session->remote_jid); |
288 if (!strcmp(jid, cmp_jid)) { | 287 if (!strcmp(jid, cmp_jid)) { |
289 g_free(cmp_jid); | 288 g_free(cmp_jid); |
290 g_list_free(values); | 289 g_list_free(values); |
291 return session; | 290 return session; |
292 } | 291 } |
293 g_free(cmp_jid); | 292 g_free(cmp_jid); |
294 } | 293 } |
295 | 294 |
296 g_list_free(values); | |
297 return NULL; | 295 return NULL; |
298 } | 296 } |
299 | 297 |
300 static GList * | 298 static GList * |
301 jabber_jingle_get_codecs(xmlnode *description) | 299 jabber_jingle_get_codecs(xmlnode *description) |
945 if (!media) { | 943 if (!media) { |
946 purple_debug_error("jingle", "Couldn't create fsrtpconference\n"); | 944 purple_debug_error("jingle", "Couldn't create fsrtpconference\n"); |
947 return FALSE; | 945 return FALSE; |
948 } | 946 } |
949 | 947 |
950 for (; contents; contents = contents->next) { | 948 for (; contents; contents = g_list_delete_link(contents, contents)) { |
951 JingleSessionContent *jsc = contents->data; | 949 JingleSessionContent *jsc = contents->data; |
952 gboolean result = FALSE; | 950 gboolean result = FALSE; |
953 | 951 |
954 /* these will need to be changed to "nice" once the libnice transmitter is finished */ | 952 /* these will need to be changed to "nice" once the libnice transmitter is finished */ |
955 if (jabber_jingle_session_content_is_vv_type(jsc, "audio")) { | 953 if (jabber_jingle_session_content_is_vv_type(jsc, "audio")) { |
967 purple_debug_error("jingle", "Couldn't create stream\n"); | 965 purple_debug_error("jingle", "Couldn't create stream\n"); |
968 purple_media_reject(media); | 966 purple_media_reject(media); |
969 return FALSE; | 967 return FALSE; |
970 } | 968 } |
971 } | 969 } |
972 g_list_free(contents); | |
973 | 970 |
974 jabber_jingle_session_set_remote_jid(session, remote_jid); | 971 jabber_jingle_session_set_remote_jid(session, remote_jid); |
975 jabber_jingle_session_set_initiator(session, initiator); | 972 jabber_jingle_session_set_initiator(session, initiator); |
976 jabber_jingle_session_set_media(session, media); | 973 jabber_jingle_session_set_media(session, media); |
977 | 974 |
1113 jabber_jingle_session_terminate_sessions(JabberStream *js) | 1110 jabber_jingle_session_terminate_sessions(JabberStream *js) |
1114 { | 1111 { |
1115 GList *values = js->sessions ? | 1112 GList *values = js->sessions ? |
1116 g_hash_table_get_values(js->sessions) : NULL; | 1113 g_hash_table_get_values(js->sessions) : NULL; |
1117 | 1114 |
1118 for (; values; values = values->next) { | 1115 for (; values; values = g_list_delete_link(values, values)) { |
1119 JingleSession *session = (JingleSession *)values->data; | 1116 JingleSession *session = (JingleSession *)values->data; |
1120 purple_media_hangup(session->media); | 1117 purple_media_hangup(session->media); |
1121 } | 1118 } |
1122 | |
1123 g_list_free(values); | |
1124 } | 1119 } |
1125 | 1120 |
1126 static void | 1121 static void |
1127 jabber_jingle_session_handle_content_replace(JingleSession *session, xmlnode *jingle) | 1122 jabber_jingle_session_handle_content_replace(JingleSession *session, xmlnode *jingle) |
1128 { | 1123 { |