[vlc-devel] commit: variables: VAR_CLASS != VAR_TYPE (Derk-Jan Hartman )

git version control git at videolan.org
Fri Sep 19 14:18:40 CEST 2008


vlc | branch: master | Derk-Jan Hartman <hartman at videolan.org> | Fri Sep 19 14:16:15 2008 +0200| [d411c31cf573a227ffee4470addeccfb9e25633d] | committer: Derk-Jan Hartman 

variables: VAR_CLASS != VAR_TYPE

This should fix a memleak with variable strings, and several other problems. Note that a CLASS detemines the basic type, and that TYPE is only a specific set within the CLASS. The variable types: VLC_VAR_KEY and VLC_VAR_INTEGER are both of CLASS integer. and thus compatible, when it comes to inheritence/init/free etc.

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

 src/misc/variables.c |   17 ++++-------------
 1 files changed, 4 insertions(+), 13 deletions(-)

diff --git a/src/misc/variables.c b/src/misc/variables.c
index bee65c4..fac5a5a 100644
--- a/src/misc/variables.c
+++ b/src/misc/variables.c
@@ -90,7 +90,7 @@ static void DupList( vlc_value_t *p_val )
     {
         p_list->p_values[i] = p_val->p_list->p_values[i];
         p_list->pi_types[i] = p_val->p_list->pi_types[i];
-        switch( p_val->p_list->pi_types[i] & VLC_VAR_TYPE )
+        switch( p_val->p_list->pi_types[i] & VLC_VAR_CLASS )
         {
         case VLC_VAR_STRING:
 
@@ -113,7 +113,7 @@ static void FreeList( vlc_value_t *p_val )
     int i;
     for( i = 0; i < p_val->p_list->i_count; i++ )
     {
-        switch( p_val->p_list->pi_types[i] & VLC_VAR_TYPE )
+        switch( p_val->p_list->pi_types[i] & VLC_VAR_CLASS )
         {
         case VLC_VAR_STRING:
             FreeString( &p_val->p_list->p_values[i] );
@@ -234,22 +234,17 @@ int __var_Create( vlc_object_t *p_this, const char *psz_name, int i_type )
     /* Always initialize the variable, even if it is a list variable; this
      * will lead to errors if the variable is not initialized, but it will
      * not cause crashes in the variable handling. */
-    switch( i_type & VLC_VAR_TYPE )
+    switch( i_type & VLC_VAR_CLASS )
     {
         case VLC_VAR_BOOL:
             p_var->pf_cmp = CmpBool;
             p_var->val.b_bool = false;
             break;
         case VLC_VAR_INTEGER:
-        case VLC_VAR_HOTKEY:
             p_var->pf_cmp = CmpInt;
             p_var->val.i_int = 0;
             break;
         case VLC_VAR_STRING:
-        case VLC_VAR_MODULE:
-        case VLC_VAR_FILE:
-        case VLC_VAR_DIRECTORY:
-        case VLC_VAR_VARIABLE:
             p_var->pf_cmp = CmpString;
             p_var->pf_dup = DupString;
             p_var->pf_free = FreeString;
@@ -1463,12 +1458,9 @@ static int InheritValue( vlc_object_t *p_this, const char *psz_name,
 
     if( !p_this->p_parent && !p_this->p_libvlc )
     {
-        switch( i_type & VLC_VAR_TYPE )
+        switch( i_type & VLC_VAR_CLASS )
         {
-        case VLC_VAR_FILE:
-        case VLC_VAR_DIRECTORY:
         case VLC_VAR_STRING:
-        case VLC_VAR_MODULE:
             p_val->psz_string = config_GetPsz( p_this, psz_name );
             if( !p_val->psz_string ) p_val->psz_string = strdup("");
             break;
@@ -1476,7 +1468,6 @@ static int InheritValue( vlc_object_t *p_this, const char *psz_name,
             p_val->f_float = config_GetFloat( p_this, psz_name );
             break;
         case VLC_VAR_INTEGER:
-        case VLC_VAR_HOTKEY:
             p_val->i_int = config_GetInt( p_this, psz_name );
             break;
         case VLC_VAR_BOOL:




More information about the vlc-devel mailing list