#endif
#include <vlc_common.h>
+#include <vlc_charset.h>
#include "variables.h"
#include "libvlc.h"
if( (p_priv->i_vars & 15) == 15 )
{
- p_priv->p_vars = realloc( p_priv->p_vars,
+ p_priv->p_vars = xrealloc( p_priv->p_vars,
(p_priv->i_vars+17) * sizeof(variable_t) );
}
if( (p_priv->i_vars & 15) == 0 )
{
- p_priv->p_vars = realloc( p_priv->p_vars,
- (p_priv->i_vars) * sizeof( variable_t ) );
+ variable_t *p_vars = realloc( p_priv->p_vars,
+ (p_priv->i_vars) * sizeof( variable_t ) );
+ if( p_vars )
+ p_priv->p_vars = p_vars;
}
p_priv->i_vars--;
p_var->psz_text = NULL;
break;
case VLC_VAR_GETTEXT:
- p_val->psz_string = NULL;
- if( p_var->psz_text )
- {
- p_val->psz_string = strdup( p_var->psz_text );
- }
+ p_val->psz_string = p_var->psz_text ? strdup( p_var->psz_text )
+ : NULL;
break;
- case VLC_VAR_INHERITVALUE:
- {
- vlc_value_t val;
-
- if( InheritValue( p_this,
- p_val2 ? p_val2->psz_string : psz_name,
- &val, p_var->i_type )
- == VLC_SUCCESS )
- {
- /* Duplicate already done */
-
- /* Backup needed stuff */
- oldval = p_var->val;
- /* Check boundaries and list */
- CheckValue( p_var, &val );
- /* Set the variable */
- p_var->val = val;
- /* Free data if needed */
- p_var->ops->pf_free( &oldval );
- }
-
- if( p_val )
- {
- *p_val = p_var->val;
- p_var->ops->pf_dup( p_val );
- }
- }
- break;
-
case VLC_VAR_SETISCOMMAND:
p_var->i_type |= VLC_VAR_ISCOMMAND;
break;
i_var = GetUnused( p_this, psz_name );
if( i_var < 0 )
{
+#ifndef NDEBUG
+ msg_Warn( p_this, "Failed to add a callback to the non-existing "
+ "variable '%s'", psz_name );
+#endif
vlc_mutex_unlock( &p_priv->var_lock );
return i_var;
}
break;
case VLC_VAR_FLOAT:
- val.f_float = atof( psz_value );
+ val.f_float = us_atof( psz_value );
break;
case VLC_VAR_STRING:
}
/*****************************************************************************
- * InheritValue: try to inherit the value of this variable from the same one
- * in our closest parent, libvlc or ultimately from the configuration.
+ * InheritValue: try to inherit the value of this variable from the closest
+ * ancestor objects or ultimately from the configuration.
* The function should always be entered with the object var_lock locked.
*****************************************************************************/
static int InheritValue( vlc_object_t *p_this, const char *psz_name,
int i_var;
variable_t *p_var;
- if( p_this->p_parent || ( p_this->p_libvlc && p_this != (vlc_object_t*) p_this->p_libvlc ) )
+ if( p_this->p_parent )
{
- vlc_object_internals_t *p_priv;
-
- if( p_this->p_parent )
- p_priv = vlc_internals( p_this->p_parent );
- else
- p_priv = vlc_internals( p_this->p_libvlc );
+ vlc_object_internals_t *p_priv = vlc_internals( p_this->p_parent );
i_var = Lookup( p_priv->p_vars, p_priv->i_vars, psz_name );
-
if( i_var >= 0 )
{
/* We found it! */
? p_this->psz_object_name : "(Unknown)" );*/
return VLC_SUCCESS;
}
- else if ( p_this->p_parent ) /* We are still not there */
- return InheritValue( p_this->p_parent, psz_name, p_val, i_type );
-
- /* else take value from config */
+ return InheritValue( p_this->p_parent, psz_name, p_val, i_type );
}
-
+ /* else take value from config */
switch( i_type & VLC_VAR_CLASS )
{
i_ret = var_SetInteger( p_obj, psz_cmd, atoi( psz_arg ) );
break;
case VLC_VAR_FLOAT:
- i_ret = var_SetFloat( p_obj, psz_cmd, atof( psz_arg ) );
+ i_ret = var_SetFloat( p_obj, psz_cmd, us_atof( psz_arg ) );
break;
case VLC_VAR_STRING:
i_ret = var_SetString( p_obj, psz_cmd, psz_arg );