]> git.sesse.net Git - vlc/blobdiff - src/misc/variables.c
Remove buggy and never used VLC_VAR_INHERITVALUE
[vlc] / src / misc / variables.c
index 1134326984892e023bff96ff6c5c141456bd117d..45d8a24faeab7ee9ad915ea3d3cc36de3279a278 100644 (file)
@@ -29,6 +29,7 @@
 #endif
 
 #include <vlc_common.h>
+#include <vlc_charset.h>
 #include "variables.h"
 
 #include "libvlc.h"
@@ -216,7 +217,7 @@ int __var_Create( vlc_object_t *p_this, const char *psz_name, int 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) );
     }
 
@@ -388,8 +389,10 @@ int __var_Destroy( vlc_object_t *p_this, const char *psz_name )
 
     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--;
@@ -621,41 +624,9 @@ int __var_Change( vlc_object_t *p_this, const char *psz_name,
                 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;
@@ -915,6 +886,10 @@ int __var_AddCallback( vlc_object_t *p_this, const char *psz_name,
     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;
     }
@@ -1121,7 +1096,7 @@ void var_OptionParse( vlc_object_t *p_obj, const char *psz_option,
         break;
 
     case VLC_VAR_FLOAT:
-        val.f_float = atof( psz_value );
+        val.f_float = us_atof( psz_value );
         break;
 
     case VLC_VAR_STRING:
@@ -1419,8 +1394,8 @@ static void CheckValue ( variable_t *p_var, vlc_value_t *p_val )
 }
 
 /*****************************************************************************
- * 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,
@@ -1429,17 +1404,11 @@ 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! */
@@ -1457,12 +1426,9 @@ static int InheritValue( vlc_object_t *p_this, const char *psz_name,
                          ? 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 )
     {
@@ -1595,7 +1561,7 @@ int __var_Command( vlc_object_t *p_this, const char *psz_name,
             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 );