[vlc-commits] Initialize submodule explicitly

Rémi Denis-Courmont git at videolan.org
Mon Aug 15 19:45:24 CEST 2011


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Aug 15 19:15:59 2011 +0300| [4fbef00c21ed4359c5599969288bcf9004a586ec] | committer: Rémi Denis-Courmont

Initialize submodule explicitly

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

 src/modules/entry.c |   24 +++++++++++++++++++-----
 1 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/src/modules/entry.c b/src/modules/entry.c
index c29c4d4..2991ad1 100644
--- a/src/modules/entry.c
+++ b/src/modules/entry.c
@@ -89,26 +89,40 @@ module_t *vlc_submodule_create (module_t *module)
 {
     assert (module != NULL);
 
-    module_t *submodule = calloc( 1, sizeof(*submodule) );
-    if( !submodule )
+    module_t *submodule = malloc (sizeof (*submodule));
+    if (unlikely(submodule == NULL))
         return NULL;
 
+    /* TODO: replace module/submodules with plugin/modules */
     vlc_gc_init (submodule, vlc_submodule_destruct);
 
     submodule->next = module->submodule;
-    submodule->parent = module;
     module->submodule = submodule;
     module->submodule_count++;
+    submodule->parent = module;
+    submodule->submodule = NULL;
+    submodule->submodule_count = 0;
 
-    /* Muahahaha! Heritage! Polymorphism! Ugliness!! */
-    submodule->pp_shortcuts = malloc( sizeof( char ** ) );
+    submodule->pp_shortcuts = xmalloc (sizeof (char **));
     submodule->pp_shortcuts[0] = module->pp_shortcuts[0]; /* object name */
     submodule->i_shortcuts = 1;
 
     submodule->psz_shortname = module->psz_shortname;
     submodule->psz_longname = module->psz_longname;
+    submodule->psz_help = NULL;
     submodule->psz_capability = module->psz_capability;
     submodule->i_score = module->i_score;
+    submodule->b_builtin = false;
+    submodule->b_loaded = false;
+    submodule->b_unloadable = false;
+    submodule->pf_activate = NULL;
+    submodule->pf_deactivate = NULL;
+    submodule->p_config = NULL;
+    submodule->confsize = 0;
+    submodule->i_config_items = 0;
+    submodule->i_bool_items = 0;
+    /*submodule->handle = unused*/
+    submodule->psz_filename = NULL;
     submodule->domain = module->domain;
     return submodule;
 }



More information about the vlc-commits mailing list