gst/: Fix memory leak in GstTypeFindFactory.
authorEdward Hervey <bilboed@bilboed.com>
Tue, 29 Nov 2005 23:56:20 +0000 (23:56 +0000)
committerEdward Hervey <bilboed@bilboed.com>
Tue, 29 Nov 2005 23:56:20 +0000 (23:56 +0000)
Original commit message from CVS:
* gst/gsttypefind.c: (gst_type_find_register):
* gst/gsttypefind.h:
* gst/gsttypefindfactory.c: (gst_type_find_factory_init),
(gst_type_find_factory_dispose):
* gst/gsttypefindfactory.h:
Fix memory leak in GstTypeFindFactory.

ChangeLog
common
gst/gsttypefind.c
gst/gsttypefind.h
gst/gsttypefindfactory.c
gst/gsttypefindfactory.h

index f994eaf..c8d1712 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2005-11-30  Edward Hervey  <edward@fluendo.com>
+
+       * gst/gsttypefind.c: (gst_type_find_register):
+       * gst/gsttypefind.h:
+       * gst/gsttypefindfactory.c: (gst_type_find_factory_init),
+       (gst_type_find_factory_dispose):
+       * gst/gsttypefindfactory.h:
+       Fix memory leak in GstTypeFindFactory.
+
 2005-11-29  Thomas Vander Stichele  <thomas (at) apestaart (dot) org>
 
        * gst/gst.c:
diff --git a/common b/common
index 33084fb..8db4c61 160000 (submodule)
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit 33084fbe0531733bc02aa1d9de608206d5553a15
+Subproject commit 8db4c613eb1aa57dc21d25a4b83b36e3cdedc5ca
index 8b9c3d2..edad5ef 100644 (file)
@@ -48,6 +48,8 @@ GST_DEBUG_CATEGORY_EXTERN (gst_type_find_debug);
  * @possible_caps: Optionally the caps that could be returned when typefinding succeeds
  * @data: Optional user data. This user data must be available until the plugin
  *       is unloaded.
+ * @data_notify: a #GDestroyNotify that will be called on @data when the plugin
+ *       is unloaded.
  *
  * Registers a new typefind function to be used for typefinding. After
  * registering this function will be available for typefinding.
@@ -58,7 +60,7 @@ GST_DEBUG_CATEGORY_EXTERN (gst_type_find_debug);
 gboolean
 gst_type_find_register (GstPlugin * plugin, const gchar * name, guint rank,
     GstTypeFindFunction func, gchar ** extensions,
-    const GstCaps * possible_caps, gpointer data)
+    const GstCaps * possible_caps, gpointer data, GDestroyNotify data_notify)
 {
   GstTypeFindFactory *factory;
 
@@ -81,6 +83,7 @@ gst_type_find_register (GstPlugin * plugin, const gchar * name, guint rank,
   gst_caps_replace (&factory->caps, (GstCaps *) possible_caps);
   factory->function = func;
   factory->user_data = data;
+  factory->user_data_notify = data_notify;
   GST_PLUGIN_FEATURE (factory)->plugin_name = g_strdup (plugin->desc.name);
   GST_PLUGIN_FEATURE (factory)->loaded = TRUE;
 
index a8e061f..71a8a0e 100644 (file)
@@ -102,7 +102,8 @@ gboolean    gst_type_find_register                  (GstPlugin *            plugin,
                                                         GstTypeFindFunction    func,
                                                         gchar **               extensions,
                                                         const GstCaps *        possible_caps,
-                                                        gpointer               data);
+                                                        gpointer               data,
+                                                        GDestroyNotify         data_notify);
 
 G_END_DECLS
 
index a4295cd..481afe0 100644 (file)
@@ -141,6 +141,7 @@ gst_type_find_factory_init (GTypeInstance * instance, gpointer g_class)
   GstTypeFindFactory *factory = GST_TYPE_FIND_FACTORY (instance);
 
   factory->user_data = factory;
+  factory->user_data_notify = NULL;
 }
 
 static void
@@ -156,6 +157,10 @@ gst_type_find_factory_dispose (GObject * object)
     g_strfreev (factory->extensions);
     factory->extensions = NULL;
   }
+  if (factory->user_data_notify && factory->user_data) {
+    factory->user_data_notify (factory->user_data);
+    factory->user_data = NULL;
+  }
 }
 
 /**
index 5ba7021..19792ee 100644 (file)
@@ -53,6 +53,7 @@ struct _GstTypeFindFactory {
   GstCaps *                    caps; /* FIXME: not yet saved in registry */
 
   gpointer                     user_data;
+  GDestroyNotify               user_data_notify;
 
   gpointer _gst_reserved[GST_PADDING];
 };