diff --git a/ChangeLog b/ChangeLog index f994eaff2b..c8d171244d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2005-11-30 Edward Hervey + + * 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 * gst/gst.c: diff --git a/common b/common index 33084fbe05..8db4c613eb 160000 --- a/common +++ b/common @@ -1 +1 @@ -Subproject commit 33084fbe0531733bc02aa1d9de608206d5553a15 +Subproject commit 8db4c613eb1aa57dc21d25a4b83b36e3cdedc5ca diff --git a/gst/gsttypefind.c b/gst/gsttypefind.c index 8b9c3d225f..edad5efc82 100644 --- a/gst/gsttypefind.c +++ b/gst/gsttypefind.c @@ -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; diff --git a/gst/gsttypefind.h b/gst/gsttypefind.h index a8e061f21f..71a8a0e1d3 100644 --- a/gst/gsttypefind.h +++ b/gst/gsttypefind.h @@ -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 diff --git a/gst/gsttypefindfactory.c b/gst/gsttypefindfactory.c index a4295cda17..481afe0f1c 100644 --- a/gst/gsttypefindfactory.c +++ b/gst/gsttypefindfactory.c @@ -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; + } } /** diff --git a/gst/gsttypefindfactory.h b/gst/gsttypefindfactory.h index 5ba7021d5f..19792eecb9 100644 --- a/gst/gsttypefindfactory.h +++ b/gst/gsttypefindfactory.h @@ -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]; };