From: Tom Tromey Date: Fri, 11 Dec 2020 16:33:36 +0000 (-0700) Subject: Change varobj_dynamic::saved_item to unique_ptr X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7446266408f6c8cdf890c23c391c0c803c7077ca;p=binutils-gdb.git 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 * varobj.c (struct varobj_dynamic) : Now unique_ptr. (varobj_clear_saved_item, update_dynamic_varobj_children): Update. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index d2c902cd4de..6e6fcfb7be3 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2020-12-11 Tom Tromey + + * varobj.c (struct varobj_dynamic) : Now unique_ptr. + (varobj_clear_saved_item, update_dynamic_varobj_children): + Update. + 2020-12-11 Tom Tromey * varobj.c (update_dynamic_varobj_children): Update. diff --git a/gdb/varobj.c b/gdb/varobj.c index e9856ea4eb3..92bb60fd9d8 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 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 (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. */