[vlc-commits] modules: remove module_t.submodule and simplify
Rémi Denis-Courmont
git at videolan.org
Thu Oct 27 21:49:16 CEST 2016
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu Oct 27 22:35:57 2016 +0300| [e8698d241f0a2475a72ff208568be2068e12ef4e] | committer: Rémi Denis-Courmont
modules: remove module_t.submodule and simplify
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e8698d241f0a2475a72ff208568be2068e12ef4e
---
src/modules/bank.c | 26 ++++++--------------------
src/modules/cache.c | 2 +-
src/modules/entry.c | 35 +++++++++++++++--------------------
src/modules/modules.h | 1 -
4 files changed, 22 insertions(+), 42 deletions(-)
diff --git a/src/modules/bank.c b/src/modules/bank.c
index 3b27acb..7bd32d0 100644
--- a/src/modules/bank.c
+++ b/src/modules/bank.c
@@ -603,7 +603,7 @@ module_t **module_list_get (size_t *n)
tab = nt;
tab[i++] = mod;
- for (module_t *subm = mod->submodule; subm; subm = subm->next)
+ for (module_t *subm = mod->next; subm != NULL; subm = subm->next)
tab[i++] = subm;
}
*n = i;
@@ -634,16 +634,9 @@ ssize_t module_list_cap (module_t ***restrict list, const char *cap)
assert (list != NULL);
for (vlc_plugin_t *lib = vlc_plugins; lib != NULL; lib = lib->next)
- {
- module_t *mod = lib->module;
- assert(mod != NULL);
-
- if (module_provides (mod, cap))
- n++;
- for (module_t *subm = mod->submodule; subm != NULL; subm = subm->next)
- if (module_provides (subm, cap))
+ for (module_t *m = lib->module; m != NULL; m = m->next)
+ if (module_provides(m, cap))
n++;
- }
module_t **tab = malloc (sizeof (*tab) * n);
*list = tab;
@@ -651,16 +644,9 @@ ssize_t module_list_cap (module_t ***restrict list, const char *cap)
return -1;
for (vlc_plugin_t *lib = vlc_plugins; lib != NULL; lib = lib->next)
- {
- module_t *mod = lib->module;
- assert(mod != NULL);
-
- if (module_provides (mod, cap))
- *(tab++)= mod;
- for (module_t *subm = mod->submodule; subm != NULL; subm = subm->next)
- if (module_provides (subm, cap))
- *(tab++) = subm;
- }
+ for (module_t *m = lib->module; m != NULL; m = m->next)
+ if (module_provides (m, cap))
+ *(tab++) = m;
assert (tab == *list + n);
qsort (*list, n, sizeof (*tab), modulecmp);
diff --git a/src/modules/cache.c b/src/modules/cache.c
index 8d90a9e..fd8adaa 100644
--- a/src/modules/cache.c
+++ b/src/modules/cache.c
@@ -640,7 +640,7 @@ static int CacheSaveBank(FILE *file, vlc_plugin_t *const *cache, size_t n)
i_submodule = module->submodule_count;
SAVE_IMMEDIATE( i_submodule );
- for (module = module->submodule; module != NULL; module = module->next)
+ for (module = module->next; module != NULL; module = module->next)
if (CacheSaveModule(file, module))
goto error;
diff --git a/src/modules/entry.c b/src/modules/entry.c
index cdafb18..e269897 100644
--- a/src/modules/entry.c
+++ b/src/modules/entry.c
@@ -44,19 +44,21 @@ module_t *vlc_module_create(vlc_plugin_t *plugin)
if (module == NULL)
return NULL;
- /* TODO: finish replacing module/submodules with plugin/modules */
+ /* NOTE XXX: For backward compatibility with preferences UIs, the first
+ * module must stay first. That defines under which module, the
+ * configuration items of the plugin belong. The order of the following
+ * entries is irrelevant. */
module_t *parent = plugin->module;
if (parent == NULL)
module->next = NULL;
else
{
- module->next = parent->submodule;
- parent->submodule = module;
+ module->next = parent->next;
+ parent->next = module;
parent->submodule_count++;
}
module->plugin = plugin;
- module->submodule = NULL;
module->submodule_count = 0;
module->psz_shortname = NULL;
@@ -78,14 +80,14 @@ module_t *vlc_module_create(vlc_plugin_t *plugin)
*/
void vlc_module_destroy (module_t *module)
{
- for (module_t *m = module->submodule, *next; m != NULL; m = next)
+ while (module != NULL)
{
- next = m->next;
- vlc_module_destroy (m);
- }
+ module_t *next = module->next;
- free (module->pp_shortcuts);
- free (module);
+ free(module->pp_shortcuts);
+ free(module);
+ module = next;
+ }
}
vlc_plugin_t *vlc_plugin_create(void)
@@ -592,16 +594,9 @@ int vlc_plugin_resolve(vlc_plugin_t *plugin, vlc_plugin_cb entry)
int ret = -1;
/* Resolve modules activate/deactivate callbacks */
- module_t *module = plugin->module;
- assert(module != NULL);
-
- if (vlc_plugin_get_symbol(syms, module->activate_name,
- &module->pf_activate)
- || vlc_plugin_get_symbol(syms, module->deactivate_name,
- &module->pf_deactivate))
- goto error;
-
- for (module = module->submodule; module != NULL; module = module->next)
+ for (module_t *module = plugin->module;
+ module != NULL;
+ module = module->next)
{
if (vlc_plugin_get_symbol(syms, module->activate_name,
&module->pf_activate)
diff --git a/src/modules/modules.h b/src/modules/modules.h
index 3dc1971..bf04563 100644
--- a/src/modules/modules.h
+++ b/src/modules/modules.h
@@ -79,7 +79,6 @@ struct module_t
{
vlc_plugin_t *plugin; /**< Plug-in/library containing the module */
module_t *next;
- module_t *submodule;
unsigned submodule_count;
/** Shortcuts to the module */
More information about the vlc-commits
mailing list