+ p_module->p_config[i].psz_value = p_orig[i].psz_value ?
+ strdup( p_orig[i].psz_value ) : NULL;
+ p_module->p_config[i].psz_value_orig = p_orig[i].psz_value ?
+ strdup( p_orig[i].psz_value ) : NULL;
+
+ p_module->p_config[i].p_lock = &p_module->object_lock;
+
+ /* duplicate the string list */
+ if( p_orig[i].i_list )
+ {
+ if( p_orig[i].ppsz_list )
+ {
+ p_module->p_config[i].ppsz_list =
+ malloc( (p_orig[i].i_list + 1) * sizeof(char *) );
+ if( p_module->p_config[i].ppsz_list )
+ {
+ for( j = 0; j < p_orig[i].i_list; j++ )
+ p_module->p_config[i].ppsz_list[j] =
+ strdup( p_orig[i].ppsz_list[j] );
+ p_module->p_config[i].ppsz_list[j] = NULL;
+ }
+ }
+ if( p_orig[i].ppsz_list_text )
+ {
+ p_module->p_config[i].ppsz_list_text =
+ malloc( (p_orig[i].i_list + 1) * sizeof(char *) );
+ if( p_module->p_config[i].ppsz_list_text )
+ {
+ for( j = 0; j < p_orig[i].i_list; j++ )
+ p_module->p_config[i].ppsz_list_text[j] =
+ strdup( _(p_orig[i].ppsz_list_text[j]) );
+ p_module->p_config[i].ppsz_list_text[j] = NULL;
+ }
+ }
+ if( p_orig[i].pi_list )
+ {
+ p_module->p_config[i].pi_list =
+ malloc( (p_orig[i].i_list + 1) * sizeof(int) );
+ if( p_module->p_config[i].pi_list )
+ {
+ for( j = 0; j < p_orig[i].i_list; j++ )
+ p_module->p_config[i].pi_list[j] =
+ p_orig[i].pi_list[j];
+ }
+ }
+ }
+
+ p_module->p_config[i].pf_callback = p_orig[i].pf_callback;
+ }
+}
+
+/*****************************************************************************
+ * 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 )
+{
+ module_config_t *p_item = p_module->p_config;
+ int i;
+
+ if( p_item == NULL )
+ {
+ return;
+ }
+
+ for( ; p_item->i_type != CONFIG_HINT_END ; p_item++ )
+ {
+ if( p_item->psz_type )
+ free( p_item->psz_type );
+
+ if( p_item->psz_name )
+ free( p_item->psz_name );
+
+ if( p_item->psz_text )
+ free( p_item->psz_text );
+
+ if( p_item->psz_longtext )
+ free( p_item->psz_longtext );
+
+ if( p_item->psz_value )
+ free( p_item->psz_value );
+
+ if( p_item->psz_value_orig )
+ free( p_item->psz_value_orig );
+
+ if( p_item->i_list )
+ {
+ for( i = 0; i < p_item->i_list; i++ )
+ {
+ if( p_item->ppsz_list && p_item->ppsz_list[i] )
+ free( p_item->ppsz_list[i] );
+ if( p_item->ppsz_list_text && p_item->ppsz_list_text[i] )
+ free( p_item->ppsz_list_text[i] );
+ }
+ if( p_item->ppsz_list ) free( p_item->ppsz_list );
+ if( p_item->ppsz_list_text ) free( p_item->ppsz_list_text );
+ if( p_item->pi_list ) free( p_item->pi_list );
+ }
+ }
+
+ free( p_module->p_config );
+ p_module->p_config = NULL;
+}
+
+/*****************************************************************************
+ * config_SetCallbacks: sets callback functions in the duplicate p_config.
+ *****************************************************************************
+ * Unfortunatly we cannot work directly with the module's config data as
+ * this module might be unloaded from memory at any time (remember HideModule).
+ * This is why we need to duplicate callbacks each time we reload the module.
+ *****************************************************************************/
+void config_SetCallbacks( module_config_t *p_new, module_config_t *p_orig )
+{
+ while( p_new->i_type != CONFIG_HINT_END )
+ {
+ p_new->pf_callback = p_orig->pf_callback;
+ p_new++;
+ p_orig++;
+ }
+}
+
+/*****************************************************************************
+ * config_UnsetCallbacks: unsets callback functions in the duplicate p_config.
+ *****************************************************************************
+ * We simply undo what we did in config_SetCallbacks.
+ *****************************************************************************/
+void config_UnsetCallbacks( module_config_t *p_new )
+{
+ while( p_new->i_type != CONFIG_HINT_END )
+ {
+ p_new->pf_callback = NULL;
+ p_new++;
+ }
+}
+
+/*****************************************************************************
+ * config_ResetAll: reset the configuration data for all the modules.
+ *****************************************************************************/
+void __config_ResetAll( vlc_object_t *p_this )
+{
+ int i_index, i;
+ vlc_list_t *p_list;
+ module_t *p_module;
+
+ /* Acquire config file lock */
+ vlc_mutex_lock( &p_this->p_vlc->config_lock );
+
+ p_list = vlc_list_find( p_this, VLC_OBJECT_MODULE, FIND_ANYWHERE );
+
+ for( i_index = 0; i_index < p_list->i_count; i_index++ )
+ {
+ p_module = (module_t *)p_list->p_values[i_index].p_object ;
+ if( p_module->b_submodule ) continue;