diff options
author | Tom Tromey <tom@tromey.com> | 2020-12-11 09:33:36 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2020-12-11 09:33:39 -0700 |
commit | 7446266408f6c8cdf890c23c391c0c803c7077ca (patch) | |
tree | 493525a9e1c2c72aa009bf0ae82320d023e3548a /gdb/varobj.c | |
parent | 60ee72f6d3bf10b4bd3ef1315c72c4551c459224 (diff) | |
download | gdb-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/varobj.c')
-rw-r--r-- | gdb/varobj.c | 12 |
1 files changed, 4 insertions, 8 deletions
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. */ |