plugins/elements/gstmultiqueue.c: Fix small leak (free GstSingleQueue structure too...
authorTim-Philipp Müller <tim@centricular.net>
Mon, 12 Mar 2007 14:23:16 +0000 (14:23 +0000)
committerTim-Philipp Müller <tim@centricular.net>
Mon, 12 Mar 2007 14:23:16 +0000 (14:23 +0000)
Original commit message from CVS:
* plugins/elements/gstmultiqueue.c: (gst_multi_queue_finalize),
(gst_single_queue_free):
Fix small leak (free GstSingleQueue structure too, not only contents).

ChangeLog
plugins/elements/gstmultiqueue.c

index 6cd7f1c..76dad09 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2007-03-12  Tim-Philipp Müller  <tim at centricular dot net>
+
+       * plugins/elements/gstmultiqueue.c: (gst_multi_queue_finalize),
+       (gst_single_queue_free):
+         Fix small leak (free GstSingleQueue structure too, not only contents).
+
 2007-03-10  Sebastien Moutte  <sebastien@moutte.net>
 
        * gst/gstbin.c:(gst_bin_add):
index 19b369d..21d9d8d 100644 (file)
@@ -77,6 +77,7 @@ struct _GstMultiQueueItem
 };
 
 static GstSingleQueue *gst_single_queue_new (GstMultiQueue * mqueue);
+static void gst_single_queue_free (GstSingleQueue * squeue);
 
 static void wake_up_next_non_linked (GstMultiQueue * mq);
 static void compute_next_non_linked (GstMultiQueue * mq);
@@ -260,19 +261,10 @@ static void
 gst_multi_queue_finalize (GObject * object)
 {
   GstMultiQueue *mqueue = GST_MULTI_QUEUE (object);
-  GList *tmp = mqueue->queues;
 
-  /* FILLME ? */
-  /* DRAIN QUEUES */
-  while (tmp) {
-    GstSingleQueue *sq = (GstSingleQueue *) tmp->data;
-
-    gst_data_queue_flush (sq->queue);
-    g_object_unref (G_OBJECT (sq->queue));
-
-    tmp = g_list_next (tmp);
-  }
+  g_list_foreach (mqueue->queues, (GFunc) gst_single_queue_free, NULL);
   g_list_free (mqueue->queues);
+  mqueue->queues = NULL;
 
   /* free/unref instance data */
   g_mutex_free (mqueue->qlock);
@@ -1000,6 +992,15 @@ single_queue_check_full (GstDataQueue * dataq, guint visible, guint bytes,
   return res;
 }
 
+static void
+gst_single_queue_free (GstSingleQueue * sq)
+{
+  /* DRAIN QUEUE */
+  gst_data_queue_flush (sq->queue);
+  g_object_unref (sq->queue);
+  g_free (sq);
+}
+
 static GstSingleQueue *
 gst_single_queue_new (GstMultiQueue * mqueue)
 {