[vlc-devel] commit: modules: Fix const char * usage and memory management. (Pierre d' Herbemont )

git version control git at videolan.org
Wed Apr 16 14:32:28 CEST 2008


vlc | branch: master | Pierre d'Herbemont <pdherbemont at videolan.org> | Wed Apr 16 14:32:15 2008 +0200| [dc078f208212bcaafa1c594fcd5cec27a145b0a6]

modules: Fix const char * usage and memory management.

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

 src/modules/modules.c |    8 ++++----
 src/modules/modules.h |    8 ++++----
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/modules/modules.c b/src/modules/modules.c
index cb2930e..332eaff 100644
--- a/src/modules/modules.c
+++ b/src/modules/modules.c
@@ -1301,7 +1301,7 @@ static module_t * AllocatePlugin( vlc_object_t * p_this, char * psz_file )
  *****************************************************************************/
 static void DupModule( module_t *p_module )
 {
-    const char **pp_shortcut;
+    char **pp_shortcut;
     int i_submodule;
 
     for( pp_shortcut = p_module->pp_shortcuts ; *pp_shortcut ; pp_shortcut++ )
@@ -1311,7 +1311,8 @@ static void DupModule( module_t *p_module )
 
     /* We strdup() these entries so that they are still valid when the
      * module is unloaded. */
-    p_module->psz_object_name = strdup( p_module->psz_object_name );
+    /* This one is a (const char *) that will never get freed. */
+    p_module->psz_object_name = p_module->psz_object_name;
     p_module->psz_capability = strdup( p_module->psz_capability );
     p_module->psz_shortname = p_module->psz_shortname ?
                                  strdup( p_module->psz_shortname ) : NULL;
@@ -1332,7 +1333,7 @@ static void DupModule( module_t *p_module )
  *****************************************************************************/
 static void UndupModule( module_t *p_module )
 {
-    const char **pp_shortcut;
+    char **pp_shortcut;
     int i_submodule;
 
     for( i_submodule = 0; i_submodule < p_module->i_children; i_submodule++ )
@@ -1345,7 +1346,6 @@ static void UndupModule( module_t *p_module )
         free( *pp_shortcut );
     }
 
-    free( p_module->psz_object_name );
     free( p_module->psz_capability );
     free( p_module->psz_shortname );
     free( p_module->psz_longname );
diff --git a/src/modules/modules.h b/src/modules/modules.h
index 156be83..db8e2a5 100644
--- a/src/modules/modules.h
+++ b/src/modules/modules.h
@@ -103,12 +103,12 @@ struct module_t
     /*
      * Variables set by the module to identify itself
      */
-    const char *psz_shortname;                              /**< Module name */
-    const char *psz_longname;                   /**< Module descriptive name */
-    const char *psz_help;        /**< Long help string for "special" modules */
+    char *psz_shortname;                              /**< Module name */
+    char *psz_longname;                   /**< Module descriptive name */
+    char *psz_help;        /**< Long help string for "special" modules */
 
     /** Shortcuts to the module */
-    const char *pp_shortcuts[ MODULE_SHORTCUT_MAX ];
+    char *pp_shortcuts[ MODULE_SHORTCUT_MAX ];
 
     char    *psz_capability;                                 /**< Capability */
     int      i_score;                          /**< Score for the capability */




More information about the vlc-devel mailing list