From: RĂ©mi Denis-Courmont Date: Wed, 24 Sep 2008 21:24:47 +0000 (+0300) Subject: Save submodules in the same order as we create/load them X-Git-Tag: 1.0.0-pre1~2921 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=f3adfbd8e84839a96e1ed9a9282c8e797c82ef56;p=vlc Save submodules in the same order as we create/load them Buggy CacheMerge assumes this (among other wrong things) --- diff --git a/src/modules/cache.c b/src/modules/cache.c index 7f4c37db19..a917a9a278 100644 --- a/src/modules/cache.c +++ b/src/modules/cache.c @@ -462,6 +462,8 @@ static int CacheLoadConfig( module_t *p_module, FILE *file ) return VLC_EGENERIC; } +static int CacheSaveSubmodule( FILE *file, module_t *p_module ); + /***************************************************************************** * SavePluginsCache: saves the plugins cache to a file *****************************************************************************/ @@ -588,23 +590,8 @@ void CacheSave( vlc_object_t *p_this ) i_submodule = pp_cache[i]->p_module->submodule_count; SAVE_IMMEDIATE( i_submodule ); - for( module_t *p_module = pp_cache[i]->p_module->submodule; - p_module != NULL; p_module = p_module->next ) - { - SAVE_STRING( p_module->psz_object_name ); - SAVE_STRING( p_module->psz_shortname ); - SAVE_STRING( p_module->psz_longname ); - SAVE_STRING( p_module->psz_help ); - for( j = 0; j < MODULE_SHORTCUT_MAX; j++ ) - { - SAVE_STRING( p_module->pp_shortcuts[j] ); // FIX - } - SAVE_STRING( p_module->psz_capability ); - SAVE_IMMEDIATE( p_module->i_score ); - SAVE_IMMEDIATE( p_module->i_cpu ); - SAVE_IMMEDIATE( p_module->b_unloadable ); - SAVE_IMMEDIATE( p_module->b_reentrant ); - } + if( CacheSaveSubmodule( file, pp_cache[i]->p_module->submodule ) ) + goto error; } /* Fill-up file size */ @@ -627,6 +614,30 @@ error: } } +static int CacheSaveSubmodule( FILE *file, module_t *p_module ) +{ + if( p_module->next && CacheSaveSubmodule( file, p_module->next ) ) + goto error; + + SAVE_STRING( p_module->psz_object_name ); + SAVE_STRING( p_module->psz_shortname ); + SAVE_STRING( p_module->psz_longname ); + SAVE_STRING( p_module->psz_help ); + for( unsigned j = 0; j < MODULE_SHORTCUT_MAX; j++ ) + SAVE_STRING( p_module->pp_shortcuts[j] ); // FIXME + + SAVE_STRING( p_module->psz_capability ); + SAVE_IMMEDIATE( p_module->i_score ); + SAVE_IMMEDIATE( p_module->i_cpu ); + SAVE_IMMEDIATE( p_module->b_unloadable ); + SAVE_IMMEDIATE( p_module->b_reentrant ); + return 0; + +error: + return -1; +} + + static int CacheSaveConfig( module_t *p_module, FILE *file ) { uint32_t i_lines = p_module->confsize;