Commit 6cdc9671 authored by Gildas Bazin's avatar Gildas Bazin

* src/misc/modules.c: small cleanup.

parent e7abe37c
...@@ -1457,44 +1457,31 @@ static char * GetWindowsError( void ) ...@@ -1457,44 +1457,31 @@ static char * GetWindowsError( void )
*****************************************************************************/ *****************************************************************************/
static void CacheLoad( vlc_object_t *p_this ) static void CacheLoad( vlc_object_t *p_this )
{ {
char *psz_filename, *psz_homedir, *psz_cachefile; char *psz_filename, *psz_homedir;
FILE *file; FILE *file;
int i, j, i_size, i_read; int i, j, i_size, i_read;
char p_cachestring[sizeof(PLUGINSCACHE_FILE COPYRIGHT_MESSAGE)]; char p_cachestring[sizeof(PLUGINSCACHE_FILE COPYRIGHT_MESSAGE)];
int *pi_cache; int *pi_cache;
module_cache_t **pp_cache = 0; module_cache_t **pp_cache = 0;
psz_cachefile = 0; // FIXME psz_homedir = p_this->p_vlc->psz_homedir;
if( !psz_cachefile || !psz_cachefile ) if( !psz_homedir )
{ {
psz_homedir = p_this->p_vlc->psz_homedir; msg_Err( p_this, "psz_homedir is null" );
if( !psz_homedir ) return;
{ }
msg_Err( p_this, "psz_homedir is null" ); psz_filename =
return; (char *)malloc( sizeof("/" CONFIG_DIR "/" PLUGINSCACHE_FILE) +
} strlen(psz_homedir) );
psz_filename =
(char *)malloc( sizeof("/" CONFIG_DIR "/" PLUGINSCACHE_FILE) +
strlen(psz_homedir) );
if( psz_filename ) if( psz_filename )
sprintf( psz_filename, "%s/" CONFIG_DIR "/" PLUGINSCACHE_FILE, sprintf( psz_filename, "%s/" CONFIG_DIR "/" PLUGINSCACHE_FILE,
psz_homedir ); psz_homedir );
if( !psz_filename ) if( !psz_filename )
{
msg_Err( p_this, "out of memory" );
return;
}
}
else
{ {
psz_filename = strdup( psz_cachefile ); msg_Err( p_this, "out of memory" );
if( !psz_filename ) return;
{
msg_Err( p_this, "out of memory" );
return;
}
} }
if( p_this->p_libvlc->p_module_bank->b_cache_delete ) if( p_this->p_libvlc->p_module_bank->b_cache_delete )
...@@ -1533,6 +1520,7 @@ static void CacheLoad( vlc_object_t *p_this ) ...@@ -1533,6 +1520,7 @@ static void CacheLoad( vlc_object_t *p_this )
for( i = 0; i < *pi_cache; i++ ) for( i = 0; i < *pi_cache; i++ )
{ {
int32_t i_size; int32_t i_size;
int i_submodules;
#define LOAD_IMMEDIATE(a) \ #define LOAD_IMMEDIATE(a) \
fread( &a, sizeof(char), sizeof(a), file ) fread( &a, sizeof(char), sizeof(a), file )
...@@ -1577,7 +1565,6 @@ static void CacheLoad( vlc_object_t *p_this ) ...@@ -1577,7 +1565,6 @@ static void CacheLoad( vlc_object_t *p_this )
LOAD_STRING( pp_cache[i]->p_module->psz_filename ); LOAD_STRING( pp_cache[i]->p_module->psz_filename );
int i_submodules;
LOAD_IMMEDIATE( i_submodules ); LOAD_IMMEDIATE( i_submodules );
while( i_submodules-- ) while( i_submodules-- )
...@@ -1707,47 +1694,34 @@ void CacheLoadConfig( module_t *p_module, FILE *file ) ...@@ -1707,47 +1694,34 @@ void CacheLoadConfig( module_t *p_module, FILE *file )
*****************************************************************************/ *****************************************************************************/
static void CacheSave( vlc_object_t *p_this ) static void CacheSave( vlc_object_t *p_this )
{ {
char *psz_filename, *psz_homedir, *psz_cachefile; char *psz_filename, *psz_homedir;
FILE *file; FILE *file;
int i, j, i_cache; int i, j, i_cache;
module_cache_t **pp_cache; module_cache_t **pp_cache;
psz_cachefile = 0; // FIXME psz_homedir = p_this->p_vlc->psz_homedir;
if( !psz_cachefile || !psz_cachefile ) if( !psz_homedir )
{ {
psz_homedir = p_this->p_vlc->psz_homedir; msg_Err( p_this, "psz_homedir is null" );
if( !psz_homedir ) return;
{ }
msg_Err( p_this, "psz_homedir is null" ); psz_filename =
return; (char *)malloc( sizeof("/" CONFIG_DIR "/" PLUGINSCACHE_FILE) +
} strlen(psz_homedir) );
psz_filename =
(char *)malloc( sizeof("/" CONFIG_DIR "/" PLUGINSCACHE_FILE) +
strlen(psz_homedir) );
if( psz_filename )
sprintf( psz_filename, "%s/" CONFIG_DIR, psz_homedir );
if( !psz_filename )
{
msg_Err( p_this, "out of memory" );
return;
}
config_CreateDir( p_this, psz_filename ); if( psz_filename )
sprintf( psz_filename, "%s/" CONFIG_DIR, psz_homedir );
strcat( psz_filename, "/" PLUGINSCACHE_FILE ); if( !psz_filename )
}
else
{ {
psz_filename = strdup( psz_cachefile ); msg_Err( p_this, "out of memory" );
if( !psz_filename ) return;
{
msg_Err( p_this, "out of memory" );
return;
}
} }
config_CreateDir( p_this, psz_filename );
strcat( psz_filename, "/" PLUGINSCACHE_FILE );
msg_Dbg( p_this, "saving plugins cache file %s", psz_filename ); msg_Dbg( p_this, "saving plugins cache file %s", psz_filename );
file = fopen( psz_filename, "w" ); file = fopen( psz_filename, "w" );
...@@ -1771,6 +1745,7 @@ static void CacheSave( vlc_object_t *p_this ) ...@@ -1771,6 +1745,7 @@ static void CacheSave( vlc_object_t *p_this )
for( i = 0; i < i_cache; i++ ) for( i = 0; i < i_cache; i++ )
{ {
int32_t i_size; int32_t i_size;
int32_t i_submodule;
#define SAVE_IMMEDIATE(a) \ #define SAVE_IMMEDIATE(a) \
fwrite( &a, sizeof(char), sizeof(a), file ) fwrite( &a, sizeof(char), sizeof(a), file )
...@@ -1809,8 +1784,8 @@ static void CacheSave( vlc_object_t *p_this ) ...@@ -1809,8 +1784,8 @@ static void CacheSave( vlc_object_t *p_this )
SAVE_STRING( pp_cache[i]->p_module->psz_filename ); SAVE_STRING( pp_cache[i]->p_module->psz_filename );
int i_submodule; i_submodule = pp_cache[i]->p_module->i_children;
SAVE_IMMEDIATE( pp_cache[i]->p_module->i_children ); SAVE_IMMEDIATE( i_submodule );
for( i_submodule = 0; i_submodule < pp_cache[i]->p_module->i_children; for( i_submodule = 0; i_submodule < pp_cache[i]->p_module->i_children;
i_submodule++ ) i_submodule++ )
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment