#endif
#include <vlc_common.h>
+#include <vlc_charset.h>
#include "variables.h"
#include "libvlc.h"
-#include "vlc_interface.h"
#include <assert.h>
/*****************************************************************************
int i_new;
variable_t *p_var;
static vlc_list_t dummy_null_list = {0, NULL, NULL};
+
+ assert( p_this );
+
vlc_object_internals_t *p_priv = vlc_internals( p_this );
vlc_mutex_lock( &p_priv->var_lock );
if( i_new >= 0 )
{
/* If the types differ, variable creation failed. */
- if( (i_type & VLC_VAR_TYPE) != (p_priv->p_vars[i_new].i_type & VLC_VAR_TYPE) )
+ if( (i_type & VLC_VAR_CLASS) != (p_priv->p_vars[i_new].i_type & VLC_VAR_CLASS) )
{
msg_Err( p_this, "Variable '%s' (0x%04x) already exist but with a different type (0x%04x)",
psz_name, p_priv->p_vars[i_new].i_type, i_type );
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) );
}
{
int i_var, i;
variable_t *p_var;
+
+ assert( p_this );
+
vlc_object_internals_t *p_priv = vlc_internals( p_this );
vlc_mutex_lock( &p_priv->var_lock );
}
/* Free callbacks if needed */
- if( p_var->p_entries )
- {
- free( p_var->p_entries );
- }
+ free( p_var->p_entries );
free( p_var->psz_name );
free( p_var->psz_text );
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--;
int i_var, i;
variable_t *p_var;
vlc_value_t oldval;
+
+ assert( p_this );
+
vlc_object_internals_t *p_priv = vlc_internals( p_this );
vlc_mutex_lock( &p_priv->var_lock );
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:
{
int i_ret = VLC_SUCCESS;
variable_t *p_var;
vlc_value_t oldval;
+
+ assert( p_this );
+
vlc_object_internals_t *p_priv = vlc_internals( p_this );
vlc_mutex_lock( &p_priv->var_lock );
int __var_Type( vlc_object_t *p_this, const char *psz_name )
{
int i_var, i_type;
+
+ assert( p_this );
+
vlc_object_internals_t *p_priv = vlc_internals( p_this );
vlc_mutex_lock( &p_priv->var_lock );
int i_ret = VLC_SUCCESS;
variable_t *p_var;
vlc_value_t oldval;
+
+ assert( p_this );
+
vlc_object_internals_t *p_priv = vlc_internals( p_this );
vlc_mutex_lock( &p_priv->var_lock );
}
p_var = &p_priv->p_vars[i_var];
- assert( (p_var->i_type & VLC_VAR_CLASS) == 0 || expected_type == 0 ||
+ assert( expected_type == 0 ||
(p_var->i_type & VLC_VAR_CLASS) == expected_type );
/* Duplicate data if needed */
int var_GetChecked( vlc_object_t *p_this, const char *psz_name,
int expected_type, vlc_value_t *p_val )
{
+ assert( p_this );
+
vlc_object_internals_t *p_priv = vlc_internals( p_this );
int i_var, err = VLC_SUCCESS;
{
variable_t *p_var = &p_priv->p_vars[i_var];
- assert( (p_var->i_type & VLC_VAR_CLASS) == 0 || expected_type == 0 ||
+ assert( expected_type == 0 ||
(p_var->i_type & VLC_VAR_CLASS) == expected_type );
/* Really get the variable */
int i_var;
variable_t *p_var;
callback_entry_t entry;
+
+ assert( p_this );
+
vlc_object_internals_t *p_priv = vlc_internals( p_this );
entry.pf_callback = pf_callback;
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;
}
{
int i_entry, i_var;
variable_t *p_var;
+#ifndef NDEBUG
+ bool b_found_similar = false;
+#endif
+
+ assert( p_this );
+
vlc_object_internals_t *p_priv = vlc_internals( p_this );
vlc_mutex_lock( &p_priv->var_lock );
}
#ifndef NDEBUG
else if( p_var->p_entries[i_entry].pf_callback == pf_callback )
- {
- msg_Warn( p_this, "Calling var_DelCallback for '%s' with the same "
- "function but not the same data.", psz_name );
- }
+ b_found_similar = true;
#endif
}
if( i_entry < 0 )
{
+#ifndef NDEBUG
+ if( b_found_similar )
+ fprintf( stderr, "Calling var_DelCallback for '%s' with the same "
+ "function but not the same data.", psz_name );
+ assert( 0 );
+#endif
vlc_mutex_unlock( &p_priv->var_lock );
return VLC_EGENERIC;
}
int i_var;
int i_ret = VLC_SUCCESS;
variable_t *p_var;
+
+ assert( p_this );
+
vlc_object_internals_t *p_priv = vlc_internals( p_this );
vlc_mutex_lock( &p_priv->var_lock );
break;
case VLC_VAR_FLOAT:
- val.f_float = atof( psz_value );
+ val.f_float = us_atof( psz_value );
break;
case VLC_VAR_STRING:
goto cleanup;
}
- var_Set( p_obj, psz_name, val );
+ __var_Set( p_obj, psz_name, val );
/* If that's a list, remove all elements allocated */
if( i_type == VLC_VAR_LIST )
*****************************************************************************/
static int GetUnused( vlc_object_t *p_this, const char *psz_name )
{
+ assert( p_this );
+
vlc_object_internals_t *p_priv = vlc_internals( p_this );
while( true )
int i_var;
int i_entries = (*pp_var)->i_entries;
callback_entry_t *p_entries = (*pp_var)->p_entries;
+
+ assert( p_this );
+
vlc_object_internals_t *p_priv = vlc_internals( p_this );
(*pp_var)->b_incallback = true;
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 );