From 4a41468ce7aa8abbf354c19c7d1bf5e8d1327048 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Mon, 30 May 2016 12:11:13 +0200 Subject: [PATCH] Use MAY_BE_LEAKED_FLAG This helps having "make check" passing with the leaks tracer enabled. https://bugzilla.gnome.org/show_bug.cgi?id=766008 --- gst/gstcaps.c | 3 +++ gst/gstdeviceproviderfactory.c | 6 +++++- gst/gstelementfactory.c | 3 +++ gst/gstpadtemplate.c | 5 +++++ gst/gsttask.c | 2 ++ libs/gst/net/gstnetclientclock.c | 5 +++++ 6 files changed, 23 insertions(+), 1 deletion(-) diff --git a/gst/gstcaps.c b/gst/gstcaps.c index c7d990b92a..7c6812951b 100644 --- a/gst/gstcaps.c +++ b/gst/gstcaps.c @@ -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); diff --git a/gst/gstdeviceproviderfactory.c b/gst/gstdeviceproviderfactory.c index 2257ad76b0..305e214b5b 100644 --- a/gst/gstdeviceproviderfactory.c +++ b/gst/gstdeviceproviderfactory.c @@ -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); diff --git a/gst/gstelementfactory.c b/gst/gstelementfactory.c index 22d420f9f2..8cc4dc602b 100644 --- a/gst/gstelementfactory.c +++ b/gst/gstelementfactory.c @@ -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)); diff --git a/gst/gstpadtemplate.c b/gst/gstpadtemplate.c index 8806dd3f1e..4c834bb635 100644 --- a/gst/gstpadtemplate.c +++ b/gst/gstpadtemplate.c @@ -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); diff --git a/gst/gsttask.c b/gst/gsttask.c index 0d2f523400..2972e06ba0 100644 --- a/gst/gsttask.c +++ b/gst/gsttask.c @@ -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); } diff --git a/libs/gst/net/gstnetclientclock.c b/libs/gst/net/gstnetclientclock.c index b8b44c3a31..0b3e4dfff9 100644 --- a/libs/gst/net/gstnetclientclock.c +++ b/libs/gst/net/gstnetclientclock.c @@ -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);