diff options
author | Tom Tromey <tom@tromey.com> | 2018-04-04 16:08:42 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2018-04-06 15:44:50 -0600 |
commit | 2c8331b987f41fa53ed371d0bbeaa3cea50bd514 (patch) | |
tree | 353e1d7956e8df37fcf4c0623140fcaeda0f2351 /gdb/value.c | |
parent | 466ce3aea9cec006b8b0e348c9021ac2c8106022 (diff) | |
download | gdb-2c8331b987f41fa53ed371d0bbeaa3cea50bd514.zip gdb-2c8331b987f41fa53ed371d0bbeaa3cea50bd514.tar.gz gdb-2c8331b987f41fa53ed371d0bbeaa3cea50bd514.tar.bz2 |
Change value::parent to a value_ref_ptr
This changes value::parent to a value_ref_ptr. This removes a bit of
manual reference count management.
gdb/ChangeLog
2018-04-06 Tom Tromey <tom@tromey.com>
* value.c (~value): Update.
(struct value) <parent>: Now a value_ref_ptr.
(value_parent, set_value_parent, value_address, value_copy):
Update.
Diffstat (limited to 'gdb/value.c')
-rw-r--r-- | gdb/value.c | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/gdb/value.c b/gdb/value.c index fcd0007..6116b68 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -181,11 +181,6 @@ struct value ~value () { - /* If there's an associated parent value, drop our reference to - it. */ - if (parent != NULL) - value_decref (parent); - if (VALUE_LVAL (this) == lval_computed) { const struct lval_funcs *funcs = location.computed.funcs; @@ -292,7 +287,7 @@ struct value /* Only used for bitfields; the containing value. This allows a single read from the target when displaying multiple bitfields. */ - struct value *parent = nullptr; + value_ref_ptr parent; /* Type of the value. */ struct type *type; @@ -1128,7 +1123,7 @@ set_value_bitsize (struct value *value, LONGEST bit) struct value * value_parent (const struct value *value) { - return value->parent; + return value->parent.get (); } /* See value.h. */ @@ -1136,12 +1131,7 @@ value_parent (const struct value *value) void set_value_parent (struct value *value, struct value *parent) { - struct value *old = value->parent; - - value->parent = parent; - if (parent != NULL) - value_incref (parent); - value_decref (old); + value->parent = value_ref_ptr (value_incref (parent)); } gdb_byte * @@ -1521,7 +1511,7 @@ value_address (const struct value *value) if (value->lval != lval_memory) return 0; if (value->parent != NULL) - return value_address (value->parent) + value->offset; + return value_address (value->parent.get ()) + value->offset; if (NULL != TYPE_DATA_LOCATION (value_type (value))) { gdb_assert (PROP_CONST == TYPE_DATA_LOCATION_KIND (value_type (value))); @@ -1700,7 +1690,7 @@ value_copy (struct value *arg) } val->unavailable = VEC_copy (range_s, arg->unavailable); val->optimized_out = VEC_copy (range_s, arg->optimized_out); - set_value_parent (val, arg->parent); + val->parent = arg->parent; if (VALUE_LVAL (val) == lval_computed) { const struct lval_funcs *funcs = val->location.computed.funcs; |