[vlc-commits] Pass struct stat pointer when looking up a plugin in the cache

Rémi Denis-Courmont git at videolan.org
Sat Aug 13 21:24:46 CEST 2011


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Aug 13 19:57:14 2011 +0300| [1661fa70fee6f5a6ad41eb223582b28f882baddd] | committer: Rémi Denis-Courmont

Pass struct stat pointer when looking up a plugin in the cache

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

 src/modules/cache.c   |   15 ++++++++-------
 src/modules/modules.c |   13 ++++++-------
 src/modules/modules.h |    2 +-
 3 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/src/modules/cache.c b/src/modules/cache.c
index 775dd71..2e9437d 100644
--- a/src/modules/cache.c
+++ b/src/modules/cache.c
@@ -38,6 +38,7 @@
 #include <errno.h>
 
 #include <sys/types.h>
+#include <sys/stat.h>
 #ifdef HAVE_UNISTD_H
 #   include <unistd.h>
 #endif
@@ -632,19 +633,19 @@ void CacheMerge( vlc_object_t *p_this, module_t *p_cache, module_t *p_module )
     p_module->b_loaded = false;
 }
 
-/*****************************************************************************
- * CacheFind: finds the cache entry corresponding to a file
- *****************************************************************************/
-module_t *CacheFind( module_bank_t *p_bank,
-                     const char *path, time_t mtime, off_t size )
+/**
+ * Looks up a plugin file in a list of cached plugins.
+ */
+module_t *CacheFind (module_bank_t *p_bank,
+                     const char *path, const struct stat *st)
 {
     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 )
+         && cache[i]->mtime == st->st_mtime
+         && cache[i]->size == st->st_size)
        {
             module_t *module = cache[i]->p_module;
             cache[i]->p_module = NULL;
diff --git a/src/modules/modules.c b/src/modules/modules.c
index fed683c..26ca697 100644
--- a/src/modules/modules.c
+++ b/src/modules/modules.c
@@ -74,7 +74,7 @@ static void AllocatePluginPath( vlc_object_t *, module_bank_t *, const char *,
 static void AllocatePluginDir( vlc_object_t *, module_bank_t *, const char *,
                                unsigned, cache_mode_t );
 static int  AllocatePluginFile( vlc_object_t *, module_bank_t *, const char *,
-                                time_t, off_t, cache_mode_t );
+                                const struct stat *, cache_mode_t );
 static module_t * AllocatePlugin( vlc_object_t *, const char *, bool );
 #endif
 static int  AllocateBuiltinModule( vlc_object_t *, int ( * ) ( module_t * ) );
@@ -945,8 +945,7 @@ static void AllocatePluginDir( vlc_object_t *p_this, module_bank_t *p_bank,
          && !strncasecmp (path + pathlen - strlen ("_plugin"LIBEXT),
                           "_plugin"LIBEXT, strlen ("_plugni"LIBEXT)))
             /* ^^ We only load files matching "lib*_plugin"LIBEXT */
-            AllocatePluginFile (p_this, p_bank, path, st.st_mtime, st.st_size,
-                                mode);
+            AllocatePluginFile (p_this, p_bank, path, &st, mode);
 
         free (path);
     }
@@ -961,7 +960,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 *path, time_t mtime, off_t size,
+                               const char *path, const struct stat *st,
                                cache_mode_t mode )
 {
     module_t * p_module = NULL;
@@ -970,7 +969,7 @@ static int AllocatePluginFile( vlc_object_t * p_this, module_bank_t *p_bank,
                 p_module->psz_object_name, p_module->psz_longname ); */
     /* Check our plugins cache first then load plugin if needed */
     if( mode == CACHE_USE )
-        p_module = CacheFind( p_bank, path, mtime, size );
+        p_module = CacheFind( p_bank, path, st );
     if( p_module == NULL )
         p_module = AllocatePlugin( p_this, path, true );
     if( p_module == NULL )
@@ -1016,8 +1015,8 @@ static int AllocatePluginFile( vlc_object_t * p_this, module_bank_t *p_bank,
     if( pp_cache[p_bank->i_cache] == NULL )
         return -1;
     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]->mtime = st->st_mtime;
+    pp_cache[p_bank->i_cache]->size = st->st_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 fd2e31d..e0a9bd7 100644
--- a/src/modules/modules.h
+++ b/src/modules/modules.h
@@ -150,6 +150,6 @@ void   CacheMerge (vlc_object_t *, module_t *, module_t *);
 void   CacheDelete(vlc_object_t *, const char *);
 size_t CacheLoad  (vlc_object_t *, const char *, module_cache_t ***);
 void   CacheSave  (vlc_object_t *, const char *, module_cache_t *const *, size_t);
-module_t * CacheFind (module_bank_t *, const char *, time_t, off_t);
+module_t * CacheFind (module_bank_t *, const char *, const struct stat *);
 
 #endif /* !LIBVLC_MODULES_H */



More information about the vlc-commits mailing list