[vlc-commits] Remove file size from plugin 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:43:42 2011 +0300| [7cc97eda8c7c684c0c4000ea63ce5c7397f9b7cf] | committer: Rémi Denis-Courmont

Remove file size from plugin cache

This avoids seeking. This data was not useful.

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

 src/modules/cache.c |   32 ++------------------------------
 1 files changed, 2 insertions(+), 30 deletions(-)

diff --git a/src/modules/cache.c b/src/modules/cache.c
index a2e96c3..775dd71 100644
--- a/src/modules/cache.c
+++ b/src/modules/cache.c
@@ -94,7 +94,7 @@ size_t CacheLoad( vlc_object_t *p_this, const char *dir, module_cache_t ***r )
     int i_size, i_read;
     char p_cachestring[sizeof(CACHE_STRING)];
     size_t i_cache;
-    int32_t i_file_size, i_marker;
+    int32_t i_marker;
 
     assert( dir != NULL );
 
@@ -114,26 +114,6 @@ size_t CacheLoad( vlc_object_t *p_this, const char *dir, module_cache_t ***r )
     }
     free( psz_filename );
 
-    /* Check the file size */
-    i_read = fread( &i_file_size, 1, sizeof(i_file_size), file );
-    if( i_read != sizeof(i_file_size) )
-    {
-        msg_Warn( p_this, "This doesn't look like a valid plugins cache "
-                  "(too short)" );
-        fclose( file );
-        return 0;
-    }
-
-    fseek( file, 0, SEEK_END );
-    if( ftell( file ) != i_file_size )
-    {
-        msg_Warn( p_this, "This doesn't look like a valid plugins cache "
-                  "(corrupted size)" );
-        fclose( file );
-        return 0;
-    }
-    fseek( file, sizeof(i_file_size), SEEK_SET );
-
     /* Check the file is a plugins cache */
     i_size = sizeof(CACHE_STRING) - 1;
     i_read = fread( p_cachestring, 1, i_size, file );
@@ -472,10 +452,6 @@ static int CacheSaveBank (FILE *file, module_cache_t *const *pp_cache,
 {
     uint32_t i_file_size = 0;
 
-    /* Empty space for file size */
-    if (fwrite (&i_file_size, sizeof (i_file_size), 1, file) != 1)
-        goto error;
-
     /* Contains version number */
     if (fputs (CACHE_STRING, file) == EOF)
         goto error;
@@ -544,11 +520,7 @@ static int CacheSaveBank (FILE *file, module_cache_t *const *pp_cache,
             goto error;
     }
 
-    /* Fill-up file size */
-    i_file_size = ftell( file );
-    fseek( file, 0, SEEK_SET );
-    if (fwrite (&i_file_size, sizeof (i_file_size), 1, file) != 1
-     || fflush (file)) /* flush libc buffers */
+    if (fflush (file)) /* flush libc buffers */
         goto error;
     return 0; /* success! */
 



More information about the vlc-commits mailing list