Use MAY_BE_LEAKED_FLAG
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Mon, 30 May 2016 10:11:13 +0000 (12:11 +0200)
committerTim-Philipp Müller <tim@centricular.com>
Thu, 2 Jun 2016 22:14:15 +0000 (23:14 +0100)
This helps having "make check" passing with the leaks tracer enabled.

https://bugzilla.gnome.org/show_bug.cgi?id=766008

gst/gstcaps.c
gst/gstdeviceproviderfactory.c
gst/gstelementfactory.c
gst/gstpadtemplate.c
gst/gsttask.c
libs/gst/net/gstnetclientclock.c

index c7d990b..7c68129 100644 (file)
@@ -423,6 +423,9 @@ gst_static_caps_get (GstStaticCaps * static_caps)
 
     *caps = gst_caps_from_string (string);
 
+    /* Caps generated from static caps are usually leaked */
+    GST_MINI_OBJECT_FLAG_SET (*caps, GST_MINI_OBJECT_FLAG_MAY_BE_LEAKED);
+
     /* convert to string */
     if (G_UNLIKELY (*caps == NULL))
       g_critical ("Could not convert static caps \"%s\"", string);
index 2257ad7..305e214 100644 (file)
@@ -294,8 +294,12 @@ gst_device_provider_factory_get (GstDeviceProviderFactory * factory)
    * an device provider at the same moment
    */
   oclass = GST_DEVICE_PROVIDER_GET_CLASS (device_provider);
-  if (!g_atomic_pointer_compare_and_exchange (&oclass->factory, NULL, factory))
+  if (!g_atomic_pointer_compare_and_exchange (&oclass->factory, NULL, factory)) {
     gst_object_unref (factory);
+  } else {
+    /* This ref will never be dropped as the class is never destroyed */
+    GST_OBJECT_FLAG_SET (factory, GST_OBJECT_FLAG_MAY_BE_LEAKED);
+  }
 
   gst_object_ref_sink (device_provider);
 
index 22d420f..8cc4dc6 100644 (file)
@@ -386,6 +386,9 @@ gst_element_factory_create (GstElementFactory * factory, const gchar * name)
   if (!g_atomic_pointer_compare_and_exchange (&oclass->elementfactory, NULL,
           factory))
     gst_object_unref (factory);
+  else
+    /* This ref will never be dropped as the class is never destroyed */
+    GST_OBJECT_FLAG_SET (factory, GST_OBJECT_FLAG_MAY_BE_LEAKED);
 
   GST_DEBUG ("created element \"%s\"", GST_OBJECT_NAME (factory));
 
index 8806dd3..4c834bb 100644 (file)
@@ -200,6 +200,8 @@ gst_pad_template_class_init (GstPadTemplateClass * klass)
 static void
 gst_pad_template_init (GstPadTemplate * templ)
 {
+  /* GstPadTemplate objects are usually leaked */
+  GST_OBJECT_FLAG_SET (templ, GST_OBJECT_FLAG_MAY_BE_LEAKED);
 }
 
 static void
@@ -395,6 +397,9 @@ gst_pad_template_set_property (GObject * object, guint prop_id,
       break;
     case PROP_CAPS:
       GST_PAD_TEMPLATE_CAPS (object) = g_value_dup_boxed (value);
+      /* GstPadTemplate are usually leaked so are their caps */
+      GST_MINI_OBJECT_FLAG_SET (GST_PAD_TEMPLATE_CAPS (object),
+          GST_MINI_OBJECT_FLAG_MAY_BE_LEAKED);
       break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
index 0d2f523..2972e06 100644 (file)
@@ -163,6 +163,8 @@ init_klass_pool (GstTaskClass * klass)
     gst_object_unref (klass->pool);
   }
   klass->pool = gst_task_pool_new ();
+  /* Classes are never destroyed so this ref will never be dropped */
+  GST_OBJECT_FLAG_SET (klass->pool, GST_OBJECT_FLAG_MAY_BE_LEAKED);
   gst_task_pool_prepare (klass->pool, NULL);
   g_mutex_unlock (&pool_lock);
 }
index b8b44c3..0b3e4df 100644 (file)
@@ -1332,6 +1332,11 @@ gst_net_client_clock_constructed (GObject * object)
         self->priv->address, "port", self->priv->port, "is-ntp",
         self->priv->is_ntp, NULL);
     clocks = g_list_prepend (clocks, cache);
+
+    /* Not actually leaked but is cached for a while before being disposed,
+     * see gst_net_client_clock_finalize, so pretend it is to not confuse
+     * tests. */
+    GST_OBJECT_FLAG_SET (cache->clock, GST_OBJECT_FLAG_MAY_BE_LEAKED);
   }
 
   cache->clocks = g_list_prepend (cache->clocks, self);