* value.c (value_from_contents_and_address): Always return
[deliverable/binutils-gdb.git] / gdb / value.c
index 39df98ec918ec1c55d0b342b9b1d962f12926079..808d37b80657c5a33b5c7f92238e07a8ffea192d 100644 (file)
@@ -627,6 +627,17 @@ value_copy (struct value *arg)
     }
   return val;
 }
+
+void
+set_value_component_location (struct value *component, struct value *whole)
+{
+  if (VALUE_LVAL (whole) == lval_internalvar)
+    VALUE_LVAL (component) = lval_internalvar_component;
+  else
+    VALUE_LVAL (component) = VALUE_LVAL (whole);
+  component->location = whole->location;
+}
+
 \f
 /* Access to the value history.  */
 
@@ -931,7 +942,7 @@ set_internalvar (struct internalvar *var, struct value *val)
      something in the value chain (i.e., before release_value is
      called), because after the error free_all_values will get called before
      long.  */
-  xfree (var->value);
+  value_free (var->value);
   var->value = newval;
   var->endian = gdbarch_byte_order (current_gdbarch);
   release_value (newval);
@@ -1426,10 +1437,7 @@ value_primitive_field (struct value *arg1, int offset,
       v->offset = (value_offset (arg1) + offset
                   + value_embedded_offset (arg1));
     }
-  VALUE_LVAL (v) = VALUE_LVAL (arg1);
-  if (VALUE_LVAL (arg1) == lval_internalvar)
-    VALUE_LVAL (v) = lval_internalvar_component;
-  v->location = arg1->location;
+  set_value_component_location (v, arg1);
   VALUE_REGNUM (v) = VALUE_REGNUM (arg1);
   VALUE_FRAME_ID (v) = VALUE_FRAME_ID (arg1);
   return v;
@@ -1704,8 +1712,7 @@ value_from_contents_and_address (struct type *type,
   else
     memcpy (value_contents_raw (v), valaddr, TYPE_LENGTH (type));
   VALUE_ADDRESS (v) = address;
-  if (address != 0)
-    VALUE_LVAL (v) = lval_memory;
+  VALUE_LVAL (v) = lval_memory;
   return v;
 }
 
This page took 0.030304 seconds and 4 git commands to generate.