soc.2008.vv: 83dfadc3: Fixed some memory leak issues involving ...

maiku at soc.pidgin.im maiku at soc.pidgin.im
Thu Jul 10 22:16:15 EDT 2008


-----------------------------------------------------------------
Revision: 83dfadc3dcb4cf8944bc61877f1e25db159b079a
Ancestor: 9df3fe2b64aa35b1333a6bc90cf76609ec75c41f
Author: maiku at soc.pidgin.im
Date: 2008-07-11T02:10:04
Branch: im.pidgin.soc.2008.vv
URL: http://d.pidgin.im/viewmtn/revision/info/83dfadc3dcb4cf8944bc61877f1e25db159b079a

Modified files:
        libpurple/media.c libpurple/protocols/jabber/jingle.c
        pidgin/gtkmedia.c

ChangeLog: 

Fixed some memory leak issues involving GLists.

-------------- next part --------------
============================================================
--- libpurple/media.c	65e3f7ba9be320a61105aeec655838be315b1a33
+++ libpurple/media.c	434f12547890caada25bf2b6f77f6c57aed01c8d
@@ -337,12 +337,11 @@ purple_media_get_overall_type(PurpleMedi
 	GList *values = g_hash_table_get_values(media->priv->sessions);
 	PurpleMediaStreamType type = PURPLE_MEDIA_NONE;
 
-	for (; values; values = values->next) {
+	for (; values; values = g_list_delete_link(values, values)) {
 		PurpleMediaSession *session = values->data;
 		type |= session->type;
 	}
 
-	g_list_free(values);
 	return type;
 }
 
@@ -458,7 +457,7 @@ purple_media_get_elements(PurpleMedia *m
 {
 	GList *values = g_hash_table_get_values(media->priv->sessions);
 
-	for (; values; values = values->next) {
+	for (; values; values = g_list_delete_link(values, values)) {
 		PurpleMediaSession *session = (PurpleMediaSession*)values->data;
 
 		if (session->type & PURPLE_MEDIA_SEND_AUDIO && audio_src)
@@ -470,8 +469,6 @@ purple_media_get_elements(PurpleMedia *m
 		if (session->type & PURPLE_MEDIA_RECV_VIDEO && video_sink)
 			*video_sink = session->sink;
 	}
-
-	g_list_free(values);
 }
 
 void 
============================================================
--- libpurple/protocols/jabber/jingle.c	4f6c358a0f0865ff3d5ae5c5b4d959e39a142c7e
+++ libpurple/protocols/jabber/jingle.c	72a3eac220c017be03942536f085adb61b42a7b5
@@ -250,17 +250,17 @@ jabber_jingle_session_destroy(JingleSess
 static void
 jabber_jingle_session_destroy(JingleSession *sess)
 {
-	GList *contents = g_hash_table_get_values(sess->contents);
+	GList *contents;
 	g_hash_table_remove(sess->js->sessions, sess->id);
 	g_free(sess->id);
 
 	if (sess->media)
 		g_object_unref(sess->media);
 
-	for (; contents; contents = contents->next)
+	for (contents = g_hash_table_get_values(sess->contents); contents;
+			contents = g_list_delete_link(contents, contents))
 		jabber_jingle_session_destroy_content(contents->data);
 
-	g_list_free(contents);
 	g_free(sess);
 }
 
@@ -278,11 +278,10 @@ jabber_jingle_session_find_by_jid(Jabber
 jabber_jingle_session_find_by_jid(JabberStream *js, const char *jid)
 {
 	GList *values = g_hash_table_get_values(js->sessions);
-	GList *iter = values;
 	gboolean use_bare = strchr(jid, '/') == NULL;
 
-	for (; iter; iter = iter->next) {
-		JingleSession *session = (JingleSession *)iter->data;
+	for (; values; values = g_list_delete_link(values, values)) {
+		JingleSession *session = (JingleSession *)values->data;
 		gchar *cmp_jid = use_bare ? jabber_get_bare_jid(session->remote_jid)
 					  : g_strdup(session->remote_jid);
 		if (!strcmp(jid, cmp_jid)) {
@@ -293,7 +292,6 @@ jabber_jingle_session_find_by_jid(Jabber
 		g_free(cmp_jid);
 	}
 
-	g_list_free(values);
 	return NULL;	
 }
 
@@ -947,7 +945,7 @@ jabber_jingle_session_initiate_media_int
 		return FALSE;
 	}
 
-	for (; contents; contents = contents->next) {
+	for (; contents; contents = g_list_delete_link(contents, contents)) {
 		JingleSessionContent *jsc = contents->data;
 		gboolean result = FALSE;
 
@@ -969,7 +967,6 @@ jabber_jingle_session_initiate_media_int
 			return FALSE;
 		}
 	}
-	g_list_free(contents);
 
 	jabber_jingle_session_set_remote_jid(session, remote_jid);
 	jabber_jingle_session_set_initiator(session, initiator);
@@ -1115,12 +1112,10 @@ jabber_jingle_session_terminate_sessions
 	GList *values = js->sessions ?
 			g_hash_table_get_values(js->sessions) : NULL;
 
-	for (; values; values = values->next) {
+	for (; values; values = g_list_delete_link(values, values)) {
 		JingleSession *session = (JingleSession *)values->data;
 		purple_media_hangup(session->media);
 	}
-
-	g_list_free(values);
 }
 
 static void
============================================================
--- pidgin/gtkmedia.c	53efcfcaee2c2adc8605c23481f7cbe3bb17297f
+++ pidgin/gtkmedia.c	ea220f60e5ff37e144b22ca5b43af3783fbe5e25
@@ -298,7 +298,7 @@ pidgin_media_ready_cb(PurpleMedia *media
 	GList *sessions = purple_media_get_session_names(media);
 	GstBus *bus;
 
-	for (; sessions; sessions = sessions->next) {
+	for (; sessions; sessions = g_list_delete_link(sessions, sessions)) {
 		if (purple_media_get_session_type(media, sessions->data) & PURPLE_MEDIA_AUDIO) {
 			if (!audiosendbin)
 				purple_media_audio_init_src(&audiosendbin, &audiosendlevel);
@@ -315,7 +315,6 @@ pidgin_media_ready_cb(PurpleMedia *media
 			purple_media_set_sink(media, sessions->data, videorecvbin);
 		}
 	}
-	g_list_free(sessions);
 
 	if (audiosendlevel && audiorecvlevel) {
 		g_object_set(gtkmedia, "send-level", audiosendlevel,


More information about the Commits mailing list