2005-09-18 Thomas Vander Stichele <thomas at apestaart dot org>
+ * gst/gst.c: (init_post), (gst_deinit):
+ * gst/gstelementfactory.c: (gst_element_factory_class_init),
+ (gst_element_factory_finalize), (gst_element_factory_cleanup):
+ * gst/gstindex.c: (gst_index_factory_class_init),
+ (gst_index_factory_finalize):
+ * gst/gstobject.c: (gst_object_dispose):
+ * gst/gstplugin.c: (gst_plugin_finalize), (gst_plugin_class_init),
+ (gst_plugin_load_file), (gst_plugin_desc_free):
+ * gst/gstpluginfeature.c: (gst_plugin_feature_class_init),
+ (gst_plugin_feature_finalize):
+ * gst/gstregistry.c: (gst_registry_class_init),
+ (gst_registry_init), (gst_registry_finalize),
+ (gst_registry_get_default), (gst_registry_deinit):
+ * gst/gstregistry.h:
+ * gst/gstregistryxml.c: (load_feature), (load_plugin):
+ various cleanups and memleak plugging. make valgrind is happy now.
+
+2005-09-18 Thomas Vander Stichele <thomas at apestaart dot org>
+
* common/check.mak:
add a check-valgrind target
{
/* don't segfault with NULL, NULL */
gst_init (NULL, NULL);
- /* allow calling twice */
+ /* allow calling twice. well, actually, thrice. */
gst_init (NULL, NULL);
}
for (i = 0; list[i]; i++) {
gst_registry_scan_path (default_registry, list[i]);
}
+ g_strfreev (list);
}
gst_registry_xml_write_cache (default_registry, registry_file);
* Call only once, before exiting.
* After this call GStreamer should not be used anymore.
*/
+
+extern GstRegistry *_gst_registry_default;
void
gst_deinit (void)
{
gst_object_unref (clock);
gst_object_unref (clock);
+ gst_registry_deinit ();
+
gst_initialized = FALSE;
}
static void gst_element_factory_class_init (GstElementFactoryClass * klass);
static void gst_element_factory_init (GstElementFactory * factory);
+static void gst_element_factory_finalize (GObject * object);
+void __gst_element_details_clear (GstElementDetails * dp);
+static void gst_element_factory_cleanup (GstElementFactory * factory);
static GstPluginFeatureClass *parent_class = NULL;
parent_class = g_type_class_peek_parent (klass);
+ gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_element_factory_finalize);
}
+
static void
gst_element_factory_init (GstElementFactory * factory)
{
factory->interfaces = NULL;
}
+static void
+gst_element_factory_finalize (GObject * object)
+{
+ GstElementFactory *factory = GST_ELEMENT_FACTORY (object);
+
+ gst_element_factory_cleanup (factory);
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
/**
* gst_element_factory_find:
* @name: name of factory to find
GstStaticPadTemplate *templ = item->data;
g_free (templ->name_template);
- /* FIXME: free caps... */
+ g_free ((gchar *) templ->static_caps.string);
+ memset (&(templ->static_caps), 0, sizeof (GstStaticCaps));
g_free (templ);
}
g_list_free (factory->staticpadtemplates);
static void gst_index_factory_class_init (GstIndexFactoryClass * klass);
static void gst_index_factory_init (GstIndexFactory * factory);
+static void gst_index_factory_finalize (GObject * object);
static GstPluginFeatureClass *factory_parent_class = NULL;
gstpluginfeature_class = (GstPluginFeatureClass *) klass;
factory_parent_class = g_type_class_ref (GST_TYPE_PLUGIN_FEATURE);
+
+ gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_index_factory_finalize);
}
static void
{
}
+static void
+gst_index_factory_finalize (GObject * object)
+{
+ GstIndexFactory *factory = GST_INDEX_FACTORY (object);
+
+ g_free (factory->longdesc);
+
+ G_OBJECT_CLASS (factory_parent_class)->finalize (object);
+
+}
+
/**
* gst_index_factory_new:
* @name: name of indexfactory to create
GST_UNLOCK (object);
/* need to patch refcount so it is finalized */
- PATCH_REFCOUNT1 (object)
+ PATCH_REFCOUNT1 (object);
- parent_class->dispose (object);
+ parent_class->dispose (object);
}
/* finalize is called when the object has to free its resources */
GModule * module, GstPluginDesc * desc);
static void
gst_plugin_desc_copy (GstPluginDesc * dest, const GstPluginDesc * src);
+static void gst_plugin_desc_free (GstPluginDesc * desc);
G_DEFINE_TYPE (GstPlugin, gst_plugin, GST_TYPE_OBJECT);
+static GstObjectClass *parent_class = NULL;
+
static void
gst_plugin_init (GstPlugin * plugin)
{
}
static void
-gst_plugin_finalize (GstPlugin * plugin)
+gst_plugin_finalize (GObject * object)
{
+ GstPlugin *plugin = GST_PLUGIN (object);
GstRegistry *registry = gst_registry_get_default ();
GList *g;
g_warning ("removing plugin that is still in registry");
}
}
+ g_free (plugin->filename);
+ gst_plugin_desc_free (&plugin->desc);
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gst_plugin_class_init (GstPluginClass * klass)
{
+ parent_class = g_type_class_ref (GST_TYPE_OBJECT);
- G_OBJECT_CLASS (klass)->finalize = (GObjectFinalizeFunc) gst_plugin_finalize;
+ G_OBJECT_CLASS (klass)->finalize = GST_DEBUG_FUNCPTR (gst_plugin_finalize);
}
GQuark
g_static_mutex_unlock (&gst_plugin_loading_mutex);
return plugin;
return_error:
+ if (plugin)
+ gst_object_unref (plugin);
g_static_mutex_unlock (&gst_plugin_loading_mutex);
return NULL;
}
dest->origin = g_strdup (src->origin);
}
-#if 0
/* unused */
static void
gst_plugin_desc_free (GstPluginDesc * desc)
memset (desc, 0, sizeof (GstPluginDesc));
}
-#endif
/**
* gst_plugin_get_name:
static void gst_plugin_feature_class_init (GstPluginFeatureClass * klass);
static void gst_plugin_feature_init (GstPluginFeature * feature);
-static void gst_plugin_feature_finalize (GstPluginFeature * feature);
+static void gst_plugin_feature_finalize (GObject * object);
/* static guint gst_plugin_feature_signals[LAST_SIGNAL] = { 0 }; */
G_DEFINE_ABSTRACT_TYPE (GstPluginFeature, gst_plugin_feature, GST_TYPE_OBJECT);
+GstObjectClass *parent_class = NULL;
static void
gst_plugin_feature_class_init (GstPluginFeatureClass * klass)
{
+ parent_class = g_type_class_ref (GST_TYPE_OBJECT);
G_OBJECT_CLASS (klass)->finalize =
- (GObjectFinalizeFunc) gst_plugin_feature_finalize;
+ GST_DEBUG_FUNCPTR (gst_plugin_feature_finalize);
}
static void
}
static void
-gst_plugin_feature_finalize (GstPluginFeature * feature)
+gst_plugin_feature_finalize (GObject * object)
{
+ GstPluginFeature *feature = GST_PLUGIN_FEATURE (object);
+
GST_DEBUG ("finalizing feature %p", feature);
+ g_free (feature->name);
+ g_free (feature->plugin_name);
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
}
/**
#define GST_CAT_DEFAULT GST_CAT_REGISTRY
+/* the one instance of the default registry */
+static GstRegistry *_gst_registry_default = NULL;
+
/*
* Design:
*
static void gst_registry_class_init (GstRegistryClass * klass);
static void gst_registry_init (GstRegistry * registry);
+static void gst_registry_finalize (GObject * object);
static guint gst_registry_signals[LAST_SIGNAL] = { 0 };
const char *filename);
G_DEFINE_TYPE (GstRegistry, gst_registry, GST_TYPE_OBJECT);
+static GstObjectClass *parent_class = NULL;
static void
gst_registry_class_init (GstRegistryClass * klass)
gobject_class = (GObjectClass *) klass;
+ parent_class = g_type_class_ref (GST_TYPE_OBJECT);
+
gst_registry_signals[PLUGIN_ADDED] =
g_signal_new ("plugin-added", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstRegistryClass, plugin_added), NULL,
G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstRegistryClass, feature_added),
NULL, NULL, gst_marshal_VOID__POINTER, G_TYPE_NONE, 1, G_TYPE_POINTER);
- gobject_class->dispose = NULL;
+ gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_registry_finalize);
}
static void
gst_registry_init (GstRegistry * registry)
{
+}
+
+static void
+gst_registry_finalize (GObject * object)
+{
+ GstRegistry *registry = GST_REGISTRY (object);
+ GList *plugins, *p;
+ GList *features, *f;
+
+ plugins = registry->plugins;
+ registry->plugins = NULL;
+
+ GST_DEBUG_OBJECT (registry, "registry finalize");
+ p = plugins;
+ while (p) {
+ GstPlugin *plugin = p->data;
+
+ if (plugin) {
+ GST_DEBUG_OBJECT (registry, "removing plugin %s",
+ gst_plugin_get_name (plugin));
+ gst_registry_remove_plugin (registry, plugin);
+ }
+ p = g_list_next (p);
+ }
+ g_list_free (plugins);
+
+ features = registry->features;
+ registry->features = NULL;
+ f = features;
+ while (f) {
+ GstPluginFeature *feature = f->data;
+
+ if (feature) {
+ GST_DEBUG_OBJECT (registry, "removing feature %s",
+ gst_plugin_feature_get_name (feature));
+ gst_registry_remove_feature (registry, feature);
+ }
+ f = g_list_next (f);
+ }
+ g_list_free (features);
+
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
}
GstRegistry *
gst_registry_get_default (void)
{
- static GstRegistry *_gst_registry_default;
-
if (!_gst_registry_default) {
_gst_registry_default = g_object_new (GST_TYPE_REGISTRY, NULL);
}
return gst_registry_feature_filter (registry,
_gst_plugin_feature_filter_plugin_name, FALSE, (gpointer) name);
}
+
+void
+gst_registry_deinit ()
+{
+ if (!_gst_registry_default)
+ return;
+
+ gst_object_unref (_gst_registry_default);
+ _gst_registry_default = NULL;
+}
void gst_registry_scan_paths (GstRegistry *registry);
void _gst_registry_remove_cache_plugins (GstRegistry *registry);
+void gst_registry_deinit (void);
+
#define gst_default_registry_add_plugin(plugin) \
gst_registry_add_plugin (gst_registry_get_default(), plugin)
#define gst_default_registry_add_path(path) \
*array = new;
}
+/* read a string and copy it into the given location */
static gboolean
read_string (xmlTextReaderPtr reader, gchar ** write_to)
{
{
int ret;
int depth = xmlTextReaderDepth (reader);
- const gchar *feature_name =
- (const gchar *) xmlTextReaderGetAttribute (reader, BAD_CAST "typename");
+ gchar *feature_name =
+ (gchar *) xmlTextReaderGetAttribute (reader, BAD_CAST "typename");
GstPluginFeature *feature;
GType type;
if (!feature_name)
return NULL;
type = g_type_from_name (feature_name);
- if (!type)
+ g_free (feature_name);
+ feature_name = NULL;
+
+ if (!type) {
return NULL;
+ }
feature = g_object_new (type, NULL);
- if (!feature)
+ if (!feature) {
return NULL;
+ }
if (!GST_IS_PLUGIN_FEATURE (feature)) {
g_object_unref (feature);
return NULL;
} else if (g_ascii_strncasecmp (s, "source", 5) == 0) {
factory->uri_type = GST_URI_SRC;
}
+ g_free (s);
}
} else if (g_str_equal (tag, "uri_protocol")) {
gchar *s = NULL;
} else if (g_str_equal (tag, "interface")) {
gchar *s = NULL;
- if (read_string (reader, &s))
+ if (read_string (reader, &s)) {
__gst_element_factory_add_interface (factory, s);
+ /* add_interface strdup's s */
+ g_free (s);
+ }
} else if (g_str_equal (tag, "padtemplate")) {
GstStaticPadTemplate *template = load_pad_template (reader);
}
}
+ g_assert_not_reached ();
return NULL;
}
}
plugin->file_mtime = strtol (s, NULL, 0);
GST_DEBUG ("mtime %d", (int) plugin->file_mtime);
+ g_free (s);
} else if (g_str_equal (tag, "size")) {
unsigned int x;
}
}
}
- g_object_unref (plugin);
+ gst_object_unref (plugin);
GST_DEBUG ("problem reading plugin");
{
/* don't segfault with NULL, NULL */
gst_init (NULL, NULL);
- /* allow calling twice */
+ /* allow calling twice. well, actually, thrice. */
gst_init (NULL, NULL);
}