]> git.sesse.net Git - vlc/commitdiff
Pass struct stat pointer when looking up a plugin in the cache
authorRémi Denis-Courmont <remi@remlab.net>
Sat, 13 Aug 2011 16:57:14 +0000 (19:57 +0300)
committerRémi Denis-Courmont <remi@remlab.net>
Sat, 13 Aug 2011 19:22:42 +0000 (22:22 +0300)
src/modules/cache.c
src/modules/modules.c
src/modules/modules.h

index 775dd712a8aa681705869711f8b2823e017df406..2e9437db4c3e0310f2a9b604fcdf2cb7c7210e4b 100644 (file)
@@ -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 *CacheFindmodule_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;
index fed683c6aa25870a02fda61e918c04506b9e8f04..26ca697807d3ad743cd686288d00a319f9579501 100644 (file)
@@ -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++;
index fd2e31ded6d5be9c3b16826dcff1cbc412a00be6..e0a9bd76598f7f52edb1cd4b93789a8f46ab6615 100644 (file)
@@ -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 */