[vlc-devel] commit: Save submodules in the same order as we create/load them ( Rémi Denis-Courmont )

git version control git at videolan.org
Wed Sep 24 23:23:00 CEST 2008


vlc | branch: master | Rémi Denis-Courmont <rdenis at simphalempin.com> | Thu Sep 25 00:24:47 2008 +0300| [f3adfbd8e84839a96e1ed9a9282c8e797c82ef56] | committer: Rémi Denis-Courmont 

Save submodules in the same order as we create/load them

Buggy CacheMerge assumes this (among other wrong things)

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f3adfbd8e84839a96e1ed9a9282c8e797c82ef56
---

 src/modules/cache.c |   45 ++++++++++++++++++++++++++++-----------------
 1 files changed, 28 insertions(+), 17 deletions(-)

diff --git a/src/modules/cache.c b/src/modules/cache.c
index 7f4c37d..a917a9a 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;




More information about the vlc-devel mailing list