Commit 99cb4886 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Use native types for plugins mtime and size

64-bits timestamp is useless if the OS only provides 32-bits.
parent 8164d69b
...@@ -58,7 +58,7 @@ static int CacheLoadConfig ( module_t *, FILE * ); ...@@ -58,7 +58,7 @@ static int CacheLoadConfig ( module_t *, FILE * );
/* Sub-version number /* Sub-version number
* (only used to avoid breakage in dev version when cache structure changes) */ * (only used to avoid breakage in dev version when cache structure changes) */
#define CACHE_SUBVERSION_NUM 13 #define CACHE_SUBVERSION_NUM 14
/* Cache filename */ /* Cache filename */
#define CACHE_NAME "plugins.dat" #define CACHE_NAME "plugins.dat"
...@@ -235,9 +235,9 @@ void CacheLoad( vlc_object_t *p_this, module_bank_t *p_bank, const char *dir ) ...@@ -235,9 +235,9 @@ void CacheLoad( vlc_object_t *p_this, module_bank_t *p_bank, const char *dir )
pp_cache[i] = xmalloc( sizeof(module_cache_t) ); pp_cache[i] = xmalloc( sizeof(module_cache_t) );
/* Load common info */ /* Load common info */
LOAD_STRING( pp_cache[i]->psz_file ); LOAD_STRING( pp_cache[i]->path );
LOAD_IMMEDIATE( pp_cache[i]->i_time ); LOAD_IMMEDIATE( pp_cache[i]->mtime );
LOAD_IMMEDIATE( pp_cache[i]->i_size ); LOAD_IMMEDIATE( pp_cache[i]->size );
pp_cache[i]->p_module = vlc_module_create(); pp_cache[i]->p_module = vlc_module_create();
...@@ -528,9 +528,9 @@ static int CacheSaveBank (FILE *file, module_cache_t *const *pp_cache, ...@@ -528,9 +528,9 @@ static int CacheSaveBank (FILE *file, module_cache_t *const *pp_cache,
uint32_t i_submodule; uint32_t i_submodule;
/* Save common info */ /* Save common info */
SAVE_STRING( pp_cache[i]->psz_file ); SAVE_STRING( pp_cache[i]->path );
SAVE_IMMEDIATE( pp_cache[i]->i_time ); SAVE_IMMEDIATE( pp_cache[i]->mtime );
SAVE_IMMEDIATE( pp_cache[i]->i_size ); SAVE_IMMEDIATE( pp_cache[i]->size );
/* Save additional infos */ /* Save additional infos */
SAVE_STRING( pp_cache[i]->p_module->psz_object_name ); SAVE_STRING( pp_cache[i]->p_module->psz_object_name );
...@@ -678,21 +678,17 @@ void CacheMerge( vlc_object_t *p_this, module_t *p_cache, module_t *p_module ) ...@@ -678,21 +678,17 @@ void CacheMerge( vlc_object_t *p_this, module_t *p_cache, module_t *p_module )
/***************************************************************************** /*****************************************************************************
* CacheFind: finds the cache entry corresponding to a file * CacheFind: finds the cache entry corresponding to a file
*****************************************************************************/ *****************************************************************************/
module_cache_t *CacheFind( module_bank_t *p_bank, const char *psz_file, module_cache_t *CacheFind( module_bank_t *p_bank,
int64_t i_time, int64_t i_size ) const char *path, time_t mtime, off_t size )
{ {
module_cache_t **pp_cache; module_cache_t **cache = p_bank->pp_loaded_cache;
int i_cache, i; size_t n = p_bank->i_loaded_cache;
pp_cache = p_bank->pp_loaded_cache; for( size_t i = 0; i < n; i++ )
i_cache = p_bank->i_loaded_cache; if( !strcmp( cache[i]->path, path )
&& cache[i]->mtime == mtime &&
for( i = 0; i < i_cache; i++ ) cache[i]->size == size )
{ return cache[i];
if( !strcmp( pp_cache[i]->psz_file, psz_file ) &&
pp_cache[i]->i_time == i_time &&
pp_cache[i]->i_size == i_size ) return pp_cache[i];
}
return NULL; return NULL;
} }
......
...@@ -73,7 +73,7 @@ static void AllocatePluginPath( vlc_object_t *, module_bank_t *, const char *, ...@@ -73,7 +73,7 @@ static void AllocatePluginPath( vlc_object_t *, module_bank_t *, const char *,
static void AllocatePluginDir( vlc_object_t *, module_bank_t *, const char *, static void AllocatePluginDir( vlc_object_t *, module_bank_t *, const char *,
unsigned ); unsigned );
static int AllocatePluginFile( vlc_object_t *, module_bank_t *, const char *, static int AllocatePluginFile( vlc_object_t *, module_bank_t *, const char *,
int64_t, int64_t ); time_t, off_t );
static module_t * AllocatePlugin( vlc_object_t *, const char * ); static module_t * AllocatePlugin( vlc_object_t *, const char * );
#endif #endif
static int AllocateBuiltinModule( vlc_object_t *, int ( * ) ( module_t * ) ); static int AllocateBuiltinModule( vlc_object_t *, int ( * ) ( module_t * ) );
...@@ -170,14 +170,14 @@ void module_EndBank( vlc_object_t *p_this, bool b_plugins ) ...@@ -170,14 +170,14 @@ void module_EndBank( vlc_object_t *p_this, bool b_plugins )
{ {
DeleteModule( p_bank, DeleteModule( p_bank,
p_bank->pp_loaded_cache[p_bank->i_loaded_cache]->p_module ); p_bank->pp_loaded_cache[p_bank->i_loaded_cache]->p_module );
free( p_bank->pp_loaded_cache[p_bank->i_loaded_cache]->psz_file ); free( p_bank->pp_loaded_cache[p_bank->i_loaded_cache]->path );
free( p_bank->pp_loaded_cache[p_bank->i_loaded_cache] ); free( p_bank->pp_loaded_cache[p_bank->i_loaded_cache] );
} }
} }
free( p_bank->pp_loaded_cache ); free( p_bank->pp_loaded_cache );
while( p_bank->i_cache-- ) while( p_bank->i_cache-- )
{ {
free( p_bank->pp_cache[p_bank->i_cache]->psz_file ); free( p_bank->pp_cache[p_bank->i_cache]->path );
free( p_bank->pp_cache[p_bank->i_cache] ); free( p_bank->pp_cache[p_bank->i_cache] );
} }
free( p_bank->pp_cache ); free( p_bank->pp_cache );
...@@ -937,8 +937,7 @@ static void AllocatePluginDir( vlc_object_t *p_this, module_bank_t *p_bank, ...@@ -937,8 +937,7 @@ static void AllocatePluginDir( vlc_object_t *p_this, module_bank_t *p_bank,
* and module_unneed. It can be removed by DeleteModule. * and module_unneed. It can be removed by DeleteModule.
*****************************************************************************/ *****************************************************************************/
static int AllocatePluginFile( vlc_object_t * p_this, module_bank_t *p_bank, static int AllocatePluginFile( vlc_object_t * p_this, module_bank_t *p_bank,
const char *psz_file, const char *path, time_t mtime, off_t size )
int64_t i_file_time, int64_t i_file_size )
{ {
module_t * p_module = NULL; module_t * p_module = NULL;
module_cache_t *p_cache_entry = NULL; module_cache_t *p_cache_entry = NULL;
...@@ -946,10 +945,10 @@ static int AllocatePluginFile( vlc_object_t * p_this, module_bank_t *p_bank, ...@@ -946,10 +945,10 @@ static int AllocatePluginFile( vlc_object_t * p_this, module_bank_t *p_bank,
/* /*
* Check our plugins cache first then load plugin if needed * Check our plugins cache first then load plugin if needed
*/ */
p_cache_entry = CacheFind( p_bank, psz_file, i_file_time, i_file_size ); p_cache_entry = CacheFind( p_bank, path, mtime, size );
if( !p_cache_entry ) if( !p_cache_entry )
{ {
p_module = AllocatePlugin( p_this, psz_file ); p_module = AllocatePlugin( p_this, path );
} }
else else
{ {
...@@ -970,7 +969,7 @@ static int AllocatePluginFile( vlc_object_t * p_this, module_bank_t *p_bank, ...@@ -970,7 +969,7 @@ static int AllocatePluginFile( vlc_object_t * p_this, module_bank_t *p_bank,
{ {
if( p_item->i_action ) if( p_item->i_action )
{ {
p_module = AllocatePlugin( p_this, psz_file ); p_module = AllocatePlugin( p_this, path );
break; break;
} }
} }
...@@ -1004,9 +1003,9 @@ static int AllocatePluginFile( vlc_object_t * p_this, module_bank_t *p_bank, ...@@ -1004,9 +1003,9 @@ static int AllocatePluginFile( vlc_object_t * p_this, module_bank_t *p_bank,
pp_cache[p_bank->i_cache] = malloc( sizeof(module_cache_t) ); pp_cache[p_bank->i_cache] = malloc( sizeof(module_cache_t) );
if( pp_cache[p_bank->i_cache] == NULL ) if( pp_cache[p_bank->i_cache] == NULL )
return -1; return -1;
pp_cache[p_bank->i_cache]->psz_file = strdup( psz_file ); pp_cache[p_bank->i_cache]->path = strdup( path );
pp_cache[p_bank->i_cache]->i_time = i_file_time; pp_cache[p_bank->i_cache]->mtime = mtime;
pp_cache[p_bank->i_cache]->i_size = i_file_size; pp_cache[p_bank->i_cache]->size = size;
pp_cache[p_bank->i_cache]->p_module = p_module; pp_cache[p_bank->i_cache]->p_module = p_module;
p_bank->pp_cache = pp_cache; p_bank->pp_cache = pp_cache;
p_bank->i_cache++; p_bank->i_cache++;
......
...@@ -54,9 +54,9 @@ typedef struct module_bank_t ...@@ -54,9 +54,9 @@ typedef struct module_bank_t
struct module_cache_t struct module_cache_t
{ {
/* Mandatory cache entry header */ /* Mandatory cache entry header */
char *psz_file; char *path;
int64_t i_time; time_t mtime;
int64_t i_size; off_t size;
/* Optional extra data */ /* Optional extra data */
module_t *p_module; module_t *p_module;
...@@ -155,6 +155,6 @@ void CacheMerge (vlc_object_t *, module_t *, module_t *); ...@@ -155,6 +155,6 @@ void CacheMerge (vlc_object_t *, module_t *, module_t *);
void CacheDelete(vlc_object_t *, const char *); void CacheDelete(vlc_object_t *, const char *);
void CacheLoad (vlc_object_t *, module_bank_t *, const char *); void CacheLoad (vlc_object_t *, module_bank_t *, const char *);
void CacheSave (vlc_object_t *, const char *, module_cache_t *const *, size_t); void CacheSave (vlc_object_t *, const char *, module_cache_t *const *, size_t);
module_cache_t * CacheFind (module_bank_t *, const char *, int64_t, int64_t); module_cache_t * CacheFind (module_bank_t *, const char *, time_t, off_t);
#endif /* !LIBVLC_MODULES_H */ #endif /* !LIBVLC_MODULES_H */
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