From 763e6a7d89eea85318e710da31a9f45f84c81888 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 23 Apr 2008 14:54:20 +0000 Subject: [PATCH] gst/gstelementfactory.c: Unref the factory after it was used the last time, not before. Original commit message from CVS: * gst/gstelementfactory.c: (gst_element_factory_make): Unref the factory after it was used the last time, not before. * gst/gstindexfactory.c: (gst_index_factory_make): Improve debugging a bit and don't leak a ref to the index factory with each call. --- ChangeLog | 9 +++++++++ gst/gstelementfactory.c | 3 ++- gst/gstindexfactory.c | 24 ++++++++++++++++++++++-- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 871ff33..5a72393 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2008-04-23 Sebastian Dröge + + * gst/gstelementfactory.c: (gst_element_factory_make): + Unref the factory after it was used the last time, not before. + + * gst/gstindexfactory.c: (gst_index_factory_make): + Improve debugging a bit and don't leak a ref to the index factory with + each call. + 2008-04-23 Stefan Kost * gst/gstregistry.c: diff --git a/gst/gstelementfactory.c b/gst/gstelementfactory.c index 02a3ce3..cf13165 100644 --- a/gst/gstelementfactory.c +++ b/gst/gstelementfactory.c @@ -472,10 +472,10 @@ gst_element_factory_make (const gchar * factoryname, const gchar * name) GST_LOG_OBJECT (factory, "found factory %p", factory); element = gst_element_factory_create (factory, name); - gst_object_unref (factory); if (element == NULL) goto create_failed; + gst_object_unref (factory); return element; /* ERRORS */ @@ -487,6 +487,7 @@ no_factory: create_failed: { GST_INFO_OBJECT (factory, "couldn't create instance!"); + gst_object_unref (factory); return NULL; } } diff --git a/gst/gstindexfactory.c b/gst/gstindexfactory.c index ced0cbe..cf268a5 100644 --- a/gst/gstindexfactory.c +++ b/gst/gstindexfactory.c @@ -205,13 +205,33 @@ GstIndex * gst_index_factory_make (const gchar * name) { GstIndexFactory *factory; + GstIndex *index; g_return_val_if_fail (name != NULL, NULL); factory = gst_index_factory_find (name); if (factory == NULL) - return NULL; + goto no_factory; + + index = gst_index_factory_create (factory); + + if (index == NULL) + goto create_failed; + + gst_object_unref (factory); + return index; - return gst_index_factory_create (factory); + /* ERRORS */ +no_factory: + { + GST_INFO ("no such index factory \"%s\"!", name); + return NULL; + } +create_failed: + { + GST_INFO_OBJECT (factory, "couldn't create instance!"); + gst_object_unref (factory); + return NULL; + } } -- 2.7.4