streamsplitter: release pending events refs
authorThiago Santos <thiago.sousa.santos@collabora.co.uk>
Wed, 26 Jan 2011 15:16:58 +0000 (12:16 -0300)
committerThiago Santos <thiago.sousa.santos@collabora.co.uk>
Wed, 26 Jan 2011 15:52:41 +0000 (12:52 -0300)
Unref pending events when disposing the streamsplitter.

Also refactor a little to replace a for with a g_list_foreach

gst/encoding/gststreamsplitter.c

index a2fa589..c473386 100644 (file)
@@ -88,6 +88,11 @@ gst_stream_splitter_dispose (GObject * object)
     stream_splitter->lock = NULL;
   }
 
+  g_list_foreach (stream_splitter->pending_events, (GFunc) gst_event_unref,
+      NULL);
+  g_list_free (stream_splitter->pending_events);
+  stream_splitter->pending_events = NULL;
+
   G_OBJECT_CLASS (gst_stream_splitter_parent_class)->dispose (object);
 }
 
@@ -173,9 +178,8 @@ gst_stream_splitter_sink_event (GstPad * pad, GstEvent * event)
   }
 
   if (flushpending) {
-    GList *tmp;
-    for (tmp = stream_splitter->pending_events; tmp; tmp = tmp->next)
-      gst_event_unref ((GstEvent *) tmp->data);
+    g_list_foreach (stream_splitter->pending_events, (GFunc) gst_event_unref,
+        NULL);
     g_list_free (stream_splitter->pending_events);
     stream_splitter->pending_events = NULL;
   }