memory management and debugging issues

Original commit message from CVS:
memory management and debugging issues
This commit is contained in:
Benjamin Otte 2003-11-05 01:38:01 +00:00
parent ea5d0235bd
commit 9cadba0df4

View file

@ -190,6 +190,7 @@ gst_plugin_load_file (const gchar *filename, GError **error)
GModule *module; GModule *module;
GstPluginDesc *desc; GstPluginDesc *desc;
struct stat file_status; struct stat file_status;
gboolean free_plugin;
g_return_val_if_fail (filename != NULL, NULL); g_return_val_if_fail (filename != NULL, NULL);
@ -222,10 +223,12 @@ gst_plugin_load_file (const gchar *filename, GError **error)
plugin = gst_registry_pool_find_plugin (desc->name); plugin = gst_registry_pool_find_plugin (desc->name);
if (!plugin) { if (!plugin) {
free_plugin = TRUE;
plugin = g_new0 (GstPlugin, 1); plugin = g_new0 (GstPlugin, 1);
plugin->filename = g_strdup (filename); plugin->filename = g_strdup (filename);
GST_DEBUG ("created new GstPlugin %p for file \"%s\"", plugin, filename); GST_DEBUG ("created new GstPlugin %p for file \"%s\"", plugin, filename);
} else { } else {
free_plugin = FALSE;
if (gst_plugin_is_loaded (plugin)) { if (gst_plugin_is_loaded (plugin)) {
if (strcmp (plugin->filename, filename) != 0) { if (strcmp (plugin->filename, filename) != 0) {
GST_WARNING ("plugin %p from file \"%s\" with same name %s is already " GST_WARNING ("plugin %p from file \"%s\" with same name %s is already "
@ -236,13 +239,14 @@ gst_plugin_load_file (const gchar *filename, GError **error)
GST_PLUGIN_ERROR_NAME_MISMATCH, GST_PLUGIN_ERROR_NAME_MISMATCH,
"already a plugin with name \"%s\" loaded", "already a plugin with name \"%s\" loaded",
desc->name); desc->name);
if (free_plugin) g_free (plugin);
return NULL; return NULL;
} }
GST_LOG ("Plugin %p for file \"%s\" already loaded, returning it now", plugin, filename); GST_LOG ("Plugin %p for file \"%s\" already loaded, returning it now", plugin, filename);
return plugin; return plugin;
} }
} }
GST_LOG ("Plugin %p for file \"%s\" prepared, called entry function...", plugin, filename); GST_LOG ("Plugin %p for file \"%s\" prepared, calling entry function...", plugin, filename);
if (gst_plugin_register_func (plugin, module, desc)) { if (gst_plugin_register_func (plugin, module, desc)) {
GST_INFO ("plugin \"%s\" loaded", plugin->filename); GST_INFO ("plugin \"%s\" loaded", plugin->filename);
@ -255,7 +259,7 @@ gst_plugin_load_file (const gchar *filename, GError **error)
GST_PLUGIN_ERROR_MODULE, GST_PLUGIN_ERROR_MODULE,
"gst_plugin_register_func failed for plugin \"%s\"", "gst_plugin_register_func failed for plugin \"%s\"",
filename); filename);
g_free (plugin); if (free_plugin) g_free (plugin);
return NULL; return NULL;
} }
} else { } else {
@ -671,8 +675,7 @@ gst_plugin_load (const gchar *name)
if (plugin) { if (plugin) {
gst_plugin_load_file (plugin->filename, &error); gst_plugin_load_file (plugin->filename, &error);
if (error) { if (error) {
GST_CAT_DEBUG (GST_CAT_PLUGIN_LOADING, "load_plugin error: %s\n", GST_WARNING ("load_plugin error: %s\n", error->message);
error->message);
g_error_free (error); g_error_free (error);
return FALSE; return FALSE;
} }