/* Sub-version number
* (only used to avoid breakage in dev version when cache structure changes) */
-#define CACHE_SUBVERSION_NUM 9
+#define CACHE_SUBVERSION_NUM 10
/* Format string for the cache filename */
#define CACHENAME_FORMAT \
{
char *psz_filename, *psz_cachedir = config_GetUserDir(VLC_CACHE_DIR);
FILE *file;
- int i, j, i_size, i_read;
+ int j, i_size, i_read;
char p_cachestring[sizeof("cache " COPYRIGHT_MESSAGE)];
- int i_cache;
- module_cache_t **pp_cache = 0;
+ unsigned i_cache;
+ module_cache_t **pp_cache = NULL;
int32_t i_file_size, i_marker;
if( !psz_cachedir ) /* XXX: this should never happen */
return;
}
- p_bank->i_loaded_cache = 0;
if (fread( &i_cache, 1, sizeof(i_cache), file ) != sizeof(i_cache) )
{
msg_Warn( p_this, "This doesn't look like a valid plugins cache "
}
if( i_cache )
- pp_cache = p_bank->pp_loaded_cache =
- xmalloc( i_cache * sizeof(void *) );
+ {
+ unsigned i_already = p_bank->i_loaded_cache;
+ pp_cache = realloc( p_bank->pp_loaded_cache,
+ (i_already + i_cache) * sizeof(*pp_cache) );
+ if( unlikely(pp_cache == NULL) )
+ i_cache = 0; /* don't load */
+ else
+ {
+ p_bank->pp_loaded_cache = pp_cache;
+ pp_cache += i_already;
+ }
+ }
#define LOAD_IMMEDIATE(a) \
if( fread( (void *)&a, sizeof(char), sizeof(a), file ) != sizeof(a) ) goto error
} \
}
- for( i = 0; i < i_cache; i++ )
+ for( unsigned i = 0; i < i_cache; i++ )
{
uint16_t i_size;
int i_submodules;
pp_cache[i] = xmalloc( sizeof(module_cache_t) );
- p_bank->i_loaded_cache++;
/* Load common info */
LOAD_STRING( pp_cache[i]->psz_file );
LOAD_IMMEDIATE( pp_cache[i]->i_time );
LOAD_IMMEDIATE( pp_cache[i]->i_size );
- pp_cache[i]->b_used = false;
pp_cache[i]->p_module = vlc_module_create( p_this );
goto error;
LOAD_STRING( pp_cache[i]->p_module->psz_filename );
+ LOAD_STRING( pp_cache[i]->p_module->domain );
+ if( pp_cache[i]->p_module->domain != NULL )
+ vlc_bindtextdomain( pp_cache[i]->p_module->domain );
LOAD_IMMEDIATE( i_submodules );
LOAD_STRING( p_module->psz_capability );
LOAD_IMMEDIATE( p_module->i_score );
LOAD_IMMEDIATE( p_module->b_unloadable );
+ LOAD_STRING( p_module->domain );
}
}
+ p_bank->i_loaded_cache += i_cache;
fclose( file );
return;
msg_Warn( p_this, "plugins cache not loaded (corrupted)" );
/* TODO: cleanup */
- p_bank->i_loaded_cache = 0;
-
fclose( file );
return;
}
goto error;
SAVE_STRING( pp_cache[i]->p_module->psz_filename );
+ SAVE_STRING( pp_cache[i]->p_module->domain );
i_submodule = pp_cache[i]->p_module->submodule_count;
SAVE_IMMEDIATE( i_submodule );
SAVE_STRING( p_module->psz_capability );
SAVE_IMMEDIATE( p_module->i_score );
SAVE_IMMEDIATE( p_module->b_unloadable );
+ SAVE_STRING( p_module->domain );
return 0;
error: