Commit 79ca9d67 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Do not access the module bank directly from the cache

parent 1661fa70
......@@ -634,23 +634,25 @@ void CacheMerge( vlc_object_t *p_this, module_t *p_cache, module_t *p_module )
}
/**
* Looks up a plugin file in a list of cached plugins.
* Looks up a plugin file in a table of cached plugins.
*/
module_t *CacheFind (module_bank_t *p_bank,
module_t *CacheFind (module_cache_t *const *entries, size_t count,
const char *path, const struct stat *st)
{
module_cache_t **cache = p_bank->pp_loaded_cache;
size_t n = p_bank->i_loaded_cache;
while (count > 0)
{
module_cache_t *entry = *(entries++);
for( size_t i = 0; i < n; i++ )
if( !strcmp( cache[i]->path, path )
&& cache[i]->mtime == st->st_mtime
&& cache[i]->size == st->st_size)
if (!strcmp (entry->path, path)
&& entry->mtime == st->st_mtime
&& entry->size == st->st_size)
{
module_t *module = cache[i]->p_module;
cache[i]->p_module = NULL;
module_t *module = entry->p_module;
entry->p_module = NULL; /* Return NULL next time */
return module;
}
count--;
}
return NULL;
}
......
......@@ -969,7 +969,8 @@ 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, st );
p_module = CacheFind (p_bank->pp_loaded_cache, p_bank->i_loaded_cache,
path, st);
if( p_module == NULL )
p_module = AllocatePlugin( p_this, path, true );
if( p_module == NULL )
......
......@@ -150,6 +150,7 @@ 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 *, const struct stat *);
module_t *CacheFind (module_cache_t *const *, size_t,
const char *, const struct stat *);
#endif /* !LIBVLC_MODULES_H */
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