[vlc-commits] modules: inline CacheAdd() and run it only as needed
Rémi Denis-Courmont
git at videolan.org
Thu Oct 27 21:00:27 CEST 2016
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu Oct 27 21:58:01 2016 +0300| [ff70442e8e35cd5c9581b0beff5d301c1e329901] | committer: Rémi Denis-Courmont
modules: inline CacheAdd() and run it only as needed
The per-directory plugins table is only used to save a new plugins
cache, in other words, in "cache reset" mode.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ff70442e8e35cd5c9581b0beff5d301c1e329901
---
src/modules/bank.c | 10 ++++++++--
src/modules/cache.c | 17 -----------------
src/modules/modules.h | 1 -
3 files changed, 8 insertions(+), 20 deletions(-)
diff --git a/src/modules/bank.c b/src/modules/bank.c
index 945c050..3b27acb 100644
--- a/src/modules/bank.c
+++ b/src/modules/bank.c
@@ -197,8 +197,14 @@ static int AllocatePluginFile (module_bank_t *bank, const char *abspath,
module_StoreBank(plugin);
- if (bank->mode != CACHE_IGNORE) /* Add entry to bank */
- CacheAdd(&bank->plugins, &bank->size, plugin);
+ if (bank->mode == CACHE_RESET) /* Add entry to to-be-saved cache */
+ {
+ bank->plugins = xrealloc(bank->plugins,
+ (bank->size + 1) * sizeof (vlc_plugin_t *));
+ bank->plugins[bank->size] = plugin;
+ bank->size++;
+ }
+
/* TODO: deal with errors */
return 0;
}
diff --git a/src/modules/cache.c b/src/modules/cache.c
index 9e0180e..b6ad4e3 100644
--- a/src/modules/cache.c
+++ b/src/modules/cache.c
@@ -744,21 +744,4 @@ vlc_plugin_t *vlc_cache_lookup(vlc_plugin_t **cache, const char *path)
return NULL;
}
-
-/** Adds entry to the cache */
-int CacheAdd(vlc_plugin_t ***cachep, size_t *countp, vlc_plugin_t *plugin)
-{
- vlc_plugin_t **cache = *cachep;
- size_t count = *countp;
-
- cache = realloc(cache, (count + 1) * sizeof (*cache));
- if (unlikely(cache == NULL))
- return -1;
-
- cache[count] = plugin;
- *cachep = cache;
- *countp = count + 1;
- return 0;
-}
-
#endif /* HAVE_DYNAMIC_PLUGINS */
diff --git a/src/modules/modules.h b/src/modules/modules.h
index 65f720d..3dc1971 100644
--- a/src/modules/modules.h
+++ b/src/modules/modules.h
@@ -130,7 +130,6 @@ void module_Unload (module_handle_t);
vlc_plugin_t *vlc_cache_load(vlc_object_t *, const char *, block_t **);
vlc_plugin_t *vlc_cache_lookup(vlc_plugin_t **, const char *relpath);
-int CacheAdd(vlc_plugin_t ***, size_t *, vlc_plugin_t *);
void CacheSave(vlc_object_t *, const char *, vlc_plugin_t *const *, size_t);
#endif /* !LIBVLC_MODULES_H */
More information about the vlc-commits
mailing list