]> git.sesse.net Git - vlc/commitdiff
variables: store a single type per list
authorRémi Denis-Courmont <remi@remlab.net>
Thu, 23 Oct 2014 17:24:01 +0000 (20:24 +0300)
committerRémi Denis-Courmont <remi@remlab.net>
Thu, 23 Oct 2014 17:36:48 +0000 (20:36 +0300)
All entries in a single list always have the same type anyway.

include/vlc_common.h
modules/lua/libs/variables.c
src/misc/variables.c

index 128177e022dada16d220568c71b81b665c80679e..367c0918dca05cacdb860274f394a0b8fabcc93e 100644 (file)
@@ -362,10 +362,9 @@ typedef union
  */
 struct vlc_list_t
 {
-    int             i_count;
-    vlc_value_t *   p_values;
-    int *           pi_types;
-
+    int          i_type;
+    int          i_count;
+    vlc_value_t *p_values;
 };
 
 /*****************************************************************************
index e1d06070764e7120343a2d799a3f23d8d76891d2..5ac95375cf9a88664fdfb2a0f000b106197222af 100644 (file)
@@ -85,8 +85,7 @@ static int vlclua_pushlist( lua_State *L, vlc_list_t *p_list )
     for( int i = 0; i < i_count; i++ )
     {
         lua_pushinteger( L, i+1 );
-        if( !vlclua_pushvalue( L, p_list->pi_types[i],
-                               p_list->p_values[i], true ) )
+        if( !vlclua_pushvalue( L, p_list->i_type, p_list->p_values[i], true ) )
              lua_pushnil( L );
         lua_settable( L, -3 );
     }
index 19b5fb725ca90c7bbc6652eab826de97b68b6a66..9dbe20874562dba16e7f0a9bb7c165f814d3ac5f 100644 (file)
@@ -103,7 +103,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_CLASS )
+        switch( p_val->p_list->i_type & VLC_VAR_CLASS )
         {
         case VLC_VAR_STRING:
             FreeString( &p_val->p_list->p_values[i] );
@@ -114,10 +114,7 @@ static void FreeList( vlc_value_t *p_val )
     }
 
     if( p_val->p_list->i_count )
-    {
         free( p_val->p_list->p_values );
-        free( p_val->p_list->pi_types );
-    }
     free( p_val->p_list );
 }
 
@@ -561,29 +558,28 @@ int var_Change( vlc_object_t *p_this, const char *psz_name,
             {
                 p_val->p_list->p_values = malloc( p_var->choices.i_count
                                                   * sizeof(vlc_value_t) );
-                p_val->p_list->pi_types = malloc( p_var->choices.i_count
-                                                  * sizeof(int) );
                 if( p_val2 )
                 {
                     p_val2->p_list->p_values =
                         malloc( p_var->choices.i_count * sizeof(vlc_value_t) );
-                    p_val2->p_list->pi_types =
-                        malloc( p_var->choices.i_count * sizeof(int) );
                 }
             }
+            p_val->p_list->i_type = p_var->i_type;
             p_val->p_list->i_count = p_var->choices.i_count;
-            if( p_val2 ) p_val2->p_list->i_count = p_var->choices.i_count;
+            if( p_val2 )
+            {
+                p_val2->p_list->i_type = VLC_VAR_STRING;
+                p_val2->p_list->i_count = p_var->choices.i_count;
+            }
             for( int i = 0 ; i < p_var->choices.i_count ; i++ )
             {
                 p_val->p_list->p_values[i] = p_var->choices.p_values[i];
-                p_val->p_list->pi_types[i] = p_var->i_type;
                 p_var->ops->pf_dup( &p_val->p_list->p_values[i] );
                 if( p_val2 )
                 {
                     p_val2->p_list->p_values[i].psz_string =
                         p_var->choices_text.p_values[i].psz_string ?
                     strdup(p_var->choices_text.p_values[i].psz_string) : NULL;
-                    p_val2->p_list->pi_types[i] = VLC_VAR_STRING;
                 }
             }
             break;
@@ -1445,10 +1441,7 @@ void var_FreeList( vlc_value_t *p_val, vlc_value_t *p_val2 )
         for( int i = 0; i < p_val2->p_list->i_count; i++ )
             free( p_val2->p_list->p_values[i].psz_string );
         if( p_val2->p_list->i_count )
-        {
             free( p_val2->p_list->p_values );
-            free( p_val2->p_list->pi_types );
-        }
         free( p_val2->p_list );
     }
 }