Commit 2f601f63 authored by Rafaël Carré's avatar Rafaël Carré

Do not leak 1 byte per variable created

parent 0451476b
...@@ -53,7 +53,13 @@ static int CmpTime( vlc_value_t v, vlc_value_t w ) ...@@ -53,7 +53,13 @@ static int CmpTime( vlc_value_t v, vlc_value_t w )
{ {
return v.i_time == w.i_time ? 0 : v.i_time > w.i_time ? 1 : -1; return v.i_time == w.i_time ? 0 : v.i_time > w.i_time ? 1 : -1;
} }
static int CmpString( vlc_value_t v, vlc_value_t w ) { return strcmp( v.psz_string, w.psz_string ); } static int CmpString( vlc_value_t v, vlc_value_t w )
{
if( !v.psz_string )
return !w.psz_string ? 0 : -1;
else
return !w.psz_string ? 1 : strcmp( v.psz_string, w.psz_string );
}
static int CmpFloat( vlc_value_t v, vlc_value_t w ) { return v.f_float == w.f_float ? 0 : v.f_float > w.f_float ? 1 : -1; } static int CmpFloat( vlc_value_t v, vlc_value_t w ) { return v.f_float == w.f_float ? 0 : v.f_float > w.f_float ? 1 : -1; }
static int CmpAddress( vlc_value_t v, vlc_value_t w ) { return v.p_address == w.p_address ? 0 : v.p_address > w.p_address ? 1 : -1; } static int CmpAddress( vlc_value_t v, vlc_value_t w ) { return v.p_address == w.p_address ? 0 : v.p_address > w.p_address ? 1 : -1; }
...@@ -61,7 +67,7 @@ static int CmpAddress( vlc_value_t v, vlc_value_t w ) { return v.p_address == w. ...@@ -61,7 +67,7 @@ static int CmpAddress( vlc_value_t v, vlc_value_t w ) { return v.p_address == w.
* Local duplication functions, and local deallocation functions * Local duplication functions, and local deallocation functions
*****************************************************************************/ *****************************************************************************/
static void DupDummy( vlc_value_t *p_val ) { (void)p_val; /* unused */ } static void DupDummy( vlc_value_t *p_val ) { (void)p_val; /* unused */ }
static void DupString( vlc_value_t *p_val ) { p_val->psz_string = strdup( p_val->psz_string ); } static void DupString( vlc_value_t *p_val ) { if( p_val->psz_string ) p_val->psz_string = strdup( p_val->psz_string ); }
static void DupList( vlc_value_t *p_val ) static void DupList( vlc_value_t *p_val )
{ {
...@@ -247,7 +253,7 @@ int __var_Create( vlc_object_t *p_this, const char *psz_name, int i_type ) ...@@ -247,7 +253,7 @@ int __var_Create( vlc_object_t *p_this, const char *psz_name, int i_type )
p_var->pf_cmp = CmpString; p_var->pf_cmp = CmpString;
p_var->pf_dup = DupString; p_var->pf_dup = DupString;
p_var->pf_free = FreeString; p_var->pf_free = FreeString;
p_var->val.psz_string = strdup( "" ); p_var->val.psz_string = NULL;
break; break;
case VLC_VAR_FLOAT: case VLC_VAR_FLOAT:
p_var->pf_cmp = CmpFloat; p_var->pf_cmp = CmpFloat;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment