[vlc-commits] Use native types for plugins mtime and size
Rémi Denis-Courmont
git at videolan.org
Thu May 12 19:35:21 CEST 2011
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu May 12 20:29:49 2011 +0300| [99cb4886a43716ef38da19020e5f90a25febee36] | committer: Rémi Denis-Courmont
Use native types for plugins mtime and size
64-bits timestamp is useless if the OS only provides 32-bits.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=99cb4886a43716ef38da19020e5f90a25febee36
---
src/modules/cache.c | 38 +++++++++++++++++---------------------
src/modules/modules.c | 21 ++++++++++-----------
src/modules/modules.h | 8 ++++----
3 files changed, 31 insertions(+), 36 deletions(-)
diff --git a/src/modules/cache.c b/src/modules/cache.c
index d24a5ab..15b2afa 100644
--- a/src/modules/cache.c
+++ b/src/modules/cache.c
@@ -58,7 +58,7 @@ static int CacheLoadConfig ( module_t *, FILE * );
/* Sub-version number
* (only used to avoid breakage in dev version when cache structure changes) */
-#define CACHE_SUBVERSION_NUM 13
+#define CACHE_SUBVERSION_NUM 14
/* Cache filename */
#define CACHE_NAME "plugins.dat"
@@ -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) );
/* Load common info */
- LOAD_STRING( pp_cache[i]->psz_file );
- LOAD_IMMEDIATE( pp_cache[i]->i_time );
- LOAD_IMMEDIATE( pp_cache[i]->i_size );
+ LOAD_STRING( pp_cache[i]->path );
+ LOAD_IMMEDIATE( pp_cache[i]->mtime );
+ LOAD_IMMEDIATE( pp_cache[i]->size );
pp_cache[i]->p_module = vlc_module_create();
@@ -528,9 +528,9 @@ static int CacheSaveBank (FILE *file, module_cache_t *const *pp_cache,
uint32_t i_submodule;
/* Save common info */
- SAVE_STRING( pp_cache[i]->psz_file );
- SAVE_IMMEDIATE( pp_cache[i]->i_time );
- SAVE_IMMEDIATE( pp_cache[i]->i_size );
+ SAVE_STRING( pp_cache[i]->path );
+ SAVE_IMMEDIATE( pp_cache[i]->mtime );
+ SAVE_IMMEDIATE( pp_cache[i]->size );
/* Save additional infos */
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 )
/*****************************************************************************
* CacheFind: finds the cache entry corresponding to a file
*****************************************************************************/
-module_cache_t *CacheFind( module_bank_t *p_bank, const char *psz_file,
- int64_t i_time, int64_t i_size )
+module_cache_t *CacheFind( module_bank_t *p_bank,
+ const char *path, time_t mtime, off_t size )
{
- module_cache_t **pp_cache;
- int i_cache, i;
-
- pp_cache = p_bank->pp_loaded_cache;
- i_cache = p_bank->i_loaded_cache;
-
- for( i = 0; i < i_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];
- }
+ module_cache_t **cache = p_bank->pp_loaded_cache;
+ size_t n = p_bank->i_loaded_cache;
+
+ for( size_t i = 0; i < n; i++ )
+ if( !strcmp( cache[i]->path, path )
+ && cache[i]->mtime == mtime &&
+ cache[i]->size == size )
+ return cache[i];
return NULL;
}
diff --git a/src/modules/modules.c b/src/modules/modules.c
index 295462b..89c83f6 100644
--- a/src/modules/modules.c
+++ b/src/modules/modules.c
@@ -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 *,
unsigned );
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 * );
#endif
static int AllocateBuiltinModule( vlc_object_t *, int ( * ) ( module_t * ) );
@@ -170,14 +170,14 @@ void module_EndBank( vlc_object_t *p_this, bool b_plugins )
{
DeleteModule( p_bank,
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 );
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 );
@@ -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.
*****************************************************************************/
static int AllocatePluginFile( vlc_object_t * p_this, module_bank_t *p_bank,
- const char *psz_file,
- int64_t i_file_time, int64_t i_file_size )
+ const char *path, time_t mtime, off_t size )
{
module_t * p_module = 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,
/*
* 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 )
{
- p_module = AllocatePlugin( p_this, psz_file );
+ p_module = AllocatePlugin( p_this, path );
}
else
{
@@ -970,7 +969,7 @@ static int AllocatePluginFile( vlc_object_t * p_this, module_bank_t *p_bank,
{
if( p_item->i_action )
{
- p_module = AllocatePlugin( p_this, psz_file );
+ p_module = AllocatePlugin( p_this, path );
break;
}
}
@@ -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) );
if( pp_cache[p_bank->i_cache] == NULL )
return -1;
- pp_cache[p_bank->i_cache]->psz_file = strdup( psz_file );
- pp_cache[p_bank->i_cache]->i_time = i_file_time;
- pp_cache[p_bank->i_cache]->i_size = i_file_size;
+ pp_cache[p_bank->i_cache]->path = strdup( path );
+ pp_cache[p_bank->i_cache]->mtime = mtime;
+ pp_cache[p_bank->i_cache]->size = size;
pp_cache[p_bank->i_cache]->p_module = p_module;
p_bank->pp_cache = pp_cache;
p_bank->i_cache++;
diff --git a/src/modules/modules.h b/src/modules/modules.h
index 4347739..bd97989 100644
--- a/src/modules/modules.h
+++ b/src/modules/modules.h
@@ -54,9 +54,9 @@ typedef struct module_bank_t
struct module_cache_t
{
/* Mandatory cache entry header */
- char *psz_file;
- int64_t i_time;
- int64_t i_size;
+ char *path;
+ time_t mtime;
+ off_t size;
/* Optional extra data */
module_t *p_module;
@@ -155,6 +155,6 @@ void CacheMerge (vlc_object_t *, module_t *, module_t *);
void CacheDelete(vlc_object_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);
-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 */
More information about the vlc-commits
mailing list