Commit 7cc97eda authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Remove file size from plugin cache

This avoids seeking. This data was not useful.
parent 48ead28e
...@@ -94,7 +94,7 @@ size_t CacheLoad( vlc_object_t *p_this, const char *dir, module_cache_t ***r ) ...@@ -94,7 +94,7 @@ size_t CacheLoad( vlc_object_t *p_this, const char *dir, module_cache_t ***r )
int i_size, i_read; int i_size, i_read;
char p_cachestring[sizeof(CACHE_STRING)]; char p_cachestring[sizeof(CACHE_STRING)];
size_t i_cache; size_t i_cache;
int32_t i_file_size, i_marker; int32_t i_marker;
assert( dir != NULL ); assert( dir != NULL );
...@@ -114,26 +114,6 @@ size_t CacheLoad( vlc_object_t *p_this, const char *dir, module_cache_t ***r ) ...@@ -114,26 +114,6 @@ size_t CacheLoad( vlc_object_t *p_this, const char *dir, module_cache_t ***r )
} }
free( psz_filename ); 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 */ /* Check the file is a plugins cache */
i_size = sizeof(CACHE_STRING) - 1; i_size = sizeof(CACHE_STRING) - 1;
i_read = fread( p_cachestring, 1, i_size, file ); i_read = fread( p_cachestring, 1, i_size, file );
...@@ -472,10 +452,6 @@ static int CacheSaveBank (FILE *file, module_cache_t *const *pp_cache, ...@@ -472,10 +452,6 @@ static int CacheSaveBank (FILE *file, module_cache_t *const *pp_cache,
{ {
uint32_t i_file_size = 0; 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 */ /* Contains version number */
if (fputs (CACHE_STRING, file) == EOF) if (fputs (CACHE_STRING, file) == EOF)
goto error; goto error;
...@@ -544,11 +520,7 @@ static int CacheSaveBank (FILE *file, module_cache_t *const *pp_cache, ...@@ -544,11 +520,7 @@ static int CacheSaveBank (FILE *file, module_cache_t *const *pp_cache,
goto error; goto error;
} }
/* Fill-up file size */ if (fflush (file)) /* flush libc buffers */
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 */
goto error; goto error;
return 0; /* success! */ return 0; /* success! */
......
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