aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2020-12-11 09:33:36 -0700
committerTom Tromey <tom@tromey.com>2020-12-11 09:33:39 -0700
commit7446266408f6c8cdf890c23c391c0c803c7077ca (patch)
tree493525a9e1c2c72aa009bf0ae82320d023e3548a /gdb
parent60ee72f6d3bf10b4bd3ef1315c72c4551c459224 (diff)
downloadgdb-7446266408f6c8cdf890c23c391c0c803c7077ca.zip
gdb-7446266408f6c8cdf890c23c391c0c803c7077ca.tar.gz
gdb-7446266408f6c8cdf890c23c391c0c803c7077ca.tar.bz2
Change varobj_dynamic::saved_item to unique_ptr
This changes varobj_dynamic::saved_item to be a unique_ptr. gdb/ChangeLog 2020-12-11 Tom Tromey <tom@tromey.com> * varobj.c (struct varobj_dynamic) <saved_item>: Now unique_ptr. (varobj_clear_saved_item, update_dynamic_varobj_children): Update.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog6
-rw-r--r--gdb/varobj.c12
2 files changed, 10 insertions, 8 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index d2c902c..6e6fcfb 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,11 @@
2020-12-11 Tom Tromey <tom@tromey.com>
+ * varobj.c (struct varobj_dynamic) <saved_item>: Now unique_ptr.
+ (varobj_clear_saved_item, update_dynamic_varobj_children):
+ Update.
+
+2020-12-11 Tom Tromey <tom@tromey.com>
+
* varobj.c (update_dynamic_varobj_children): Update.
* varobj-iter.h (struct varobj_iter) <next>: Change return type.
* python/py-varobj.c (struct py_varobj_iter) <next>: Change return
diff --git a/gdb/varobj.c b/gdb/varobj.c
index e9856ea..92bb60f 100644
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -131,7 +131,7 @@ struct varobj_dynamic
already reported. However, we don't want to install this value
when we read it, because that will mess up future updates. So,
we stash it here instead. */
- varobj_item *saved_item = NULL;
+ std::unique_ptr<varobj_item> saved_item;
};
/* Private function prototypes */
@@ -680,8 +680,7 @@ varobj_clear_saved_item (struct varobj_dynamic *var)
if (var->saved_item != NULL)
{
value_decref (var->saved_item->value);
- delete var->saved_item;
- var->saved_item = NULL;
+ var->saved_item.reset (nullptr);
}
}
@@ -723,10 +722,7 @@ update_dynamic_varobj_children (struct varobj *var,
/* See if there was a leftover from last time. */
if (var->dynamic->saved_item != NULL)
- {
- item = std::unique_ptr<varobj_item> (var->dynamic->saved_item);
- var->dynamic->saved_item = NULL;
- }
+ item = std::move (var->dynamic->saved_item);
else
{
item = var->dynamic->child_iter->next ();
@@ -757,7 +753,7 @@ update_dynamic_varobj_children (struct varobj *var,
}
else
{
- var->dynamic->saved_item = item.release ();
+ var->dynamic->saved_item = std::move (item);
/* We want to truncate the child list just before this
element. */