[vlc-commits] Clean up config_Free()
Rémi Denis-Courmont
git at videolan.org
Tue Aug 16 18:20:56 CEST 2011
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Aug 16 11:44:58 2011 +0300| [d4b0d0c82525b87b903ced1dd5a85fd126d5811d] | committer: Rémi Denis-Courmont
Clean up config_Free()
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d4b0d0c82525b87b903ced1dd5a85fd126d5811d
---
src/config/configuration.h | 2 +-
src/config/core.c | 29 ++++++++++++-----------------
src/modules/entry.c | 2 ++
src/modules/modules.c | 2 --
4 files changed, 15 insertions(+), 20 deletions(-)
diff --git a/src/config/configuration.h b/src/config/configuration.h
index 78ff73c..f2ac54d 100644
--- a/src/config/configuration.h
+++ b/src/config/configuration.h
@@ -30,7 +30,7 @@ extern "C" {
int config_CreateDir( vlc_object_t *, const char * );
int config_AutoSaveConfigFile( vlc_object_t * );
-void config_Free( module_t * );
+void config_Free (module_config_t *, size_t);
int config_LoadCmdLine ( vlc_object_t *, int, const char *[], int * );
int config_LoadConfigFile( vlc_object_t * );
diff --git a/src/config/core.c b/src/config/core.c
index 4bc2519..d575061 100644
--- a/src/config/core.c
+++ b/src/config/core.c
@@ -420,18 +420,16 @@ module_config_t *config_FindConfig (vlc_object_t *p_this, const char *name)
return p ? *p : NULL;
}
-/*****************************************************************************
- * config_Free: frees a duplicated module's configuration data.
- *****************************************************************************
- * This function frees all the data duplicated by config_Duplicate.
- *****************************************************************************/
-void config_Free( module_t *p_module )
+/**
+ * Destroys an array of configuration items.
+ * \param config start of array of items
+ * \param confsize number of items in the array
+ */
+void config_Free (module_config_t *config, size_t confsize)
{
- int i;
-
- for (size_t j = 0; j < p_module->confsize; j++)
+ for (size_t j = 0; j < confsize; j++)
{
- module_config_t *p_item = p_module->p_config + j;
+ module_config_t *p_item = config + j;
free( p_item->psz_type );
free( p_item->psz_name );
@@ -446,10 +444,10 @@ void config_Free( module_t *p_module )
}
if( p_item->ppsz_list )
- for( i = 0; i < p_item->i_list; i++ )
+ for (int i = 0; i < p_item->i_list; i++)
free( p_item->ppsz_list[i] );
if( p_item->ppsz_list_text )
- for( i = 0; i < p_item->i_list; i++ )
+ for (int i = 0; i < p_item->i_list; i++)
free( p_item->ppsz_list_text[i] );
free( p_item->ppsz_list );
free( p_item->ppsz_list_text );
@@ -457,17 +455,14 @@ void config_Free( module_t *p_module )
if( p_item->i_action )
{
- for( i = 0; i < p_item->i_action; i++ )
- {
+ for (int i = 0; i < p_item->i_action; i++)
free( p_item->ppsz_action_text[i] );
- }
free( p_item->ppf_action );
free( p_item->ppsz_action_text );
}
}
- free (p_module->p_config);
- p_module->p_config = NULL;
+ free (config);
}
#undef config_ResetAll
diff --git a/src/modules/entry.c b/src/modules/entry.c
index a26c466..989d5b9 100644
--- a/src/modules/entry.c
+++ b/src/modules/entry.c
@@ -91,6 +91,8 @@ void vlc_module_destroy (module_t *module)
vlc_module_destroy (m);
}
+ config_Free (module->p_config, module->confsize);
+
free (module->domain);
free (module->psz_filename);
for (unsigned i = 0; i < module->i_shortcuts; i++)
diff --git a/src/modules/modules.c b/src/modules/modules.c
index b1f4d4b..05e2841 100644
--- a/src/modules/modules.c
+++ b/src/modules/modules.c
@@ -1053,7 +1053,5 @@ static void DeleteModule (module_t **head, module_t *p_module)
if (p_module->b_loaded && p_module->b_unloadable)
module_Unload (p_module->handle);
#endif
-
- config_Free( p_module );
vlc_module_destroy (p_module);
}
More information about the vlc-commits
mailing list