[vlc-commits] variables: store a single type per list
Rémi Denis-Courmont
git at videolan.org
Thu Oct 23 19:42:53 CEST 2014
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu Oct 23 20:24:01 2014 +0300| [b893d33da2b098863e49229d16bdf45755ae7668] | committer: Rémi Denis-Courmont
variables: store a single type per list
All entries in a single list always have the same type anyway.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b893d33da2b098863e49229d16bdf45755ae7668
---
include/vlc_common.h | 7 +++----
modules/lua/libs/variables.c | 3 +--
src/misc/variables.c | 21 +++++++--------------
3 files changed, 11 insertions(+), 20 deletions(-)
diff --git a/include/vlc_common.h b/include/vlc_common.h
index 128177e..367c091 100644
--- a/include/vlc_common.h
+++ b/include/vlc_common.h
@@ -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;
};
/*****************************************************************************
diff --git a/modules/lua/libs/variables.c b/modules/lua/libs/variables.c
index e1d0607..5ac9537 100644
--- a/modules/lua/libs/variables.c
+++ b/modules/lua/libs/variables.c
@@ -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 );
}
diff --git a/src/misc/variables.c b/src/misc/variables.c
index 19b5fb7..9dbe208 100644
--- a/src/misc/variables.c
+++ b/src/misc/variables.c
@@ -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 );
}
}
More information about the vlc-commits
mailing list