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:40 -0700 |
commit | 24fd95b4cd40f0108299c02f31f2d2a129f83769 (patch) | |
tree | 6ec333c8b503bf0d1977889bcebba980dd1b24c9 /gdb/varobj.c | |
parent | 7446266408f6c8cdf890c23c391c0c803c7077ca (diff) | |
download | gdb-24fd95b4cd40f0108299c02f31f2d2a129f83769.zip gdb-24fd95b4cd40f0108299c02f31f2d2a129f83769.tar.gz gdb-24fd95b4cd40f0108299c02f31f2d2a129f83769.tar.bz2 |
Change varobj_dynamic::child_iter to unique_ptr
This changes varobj_dynamic::child_iter to be a unique_ptr, removing
some manual management.
gdb/ChangeLog
2020-12-11 Tom Tromey <tom@tromey.com>
* varobj.c (struct varobj_dynamic) <child_iter>: Now unique_ptr.
(varobj_get_iterator): Return unique_ptr.
(update_dynamic_varobj_children, install_visualizer)
(varobj::~varobj): Update.
* python/python-internal.h (py_varobj_get_iterator): Return
unique_ptr.
* python/py-varobj.c (py_varobj_get_iterator): Return unique_ptr.
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 92bb60f..53e33b5 100644 --- a/gdb/varobj.c +++ b/gdb/varobj.c @@ -124,7 +124,7 @@ struct varobj_dynamic /* The iterator returned by the printer's 'children' method, or NULL if not available. */ - struct varobj_iter *child_iter = NULL; + std::unique_ptr<varobj_iter> child_iter; /* We request one extra item from the iterator, so that we can report to the caller whether there are more items than we have @@ -660,7 +660,7 @@ dynamic_varobj_has_child_method (const struct varobj *var) /* A factory for creating dynamic varobj's iterators. Returns an iterator object suitable for iterating over VAR's children. */ -static struct varobj_iter * +static std::unique_ptr<varobj_iter> varobj_get_iterator (struct varobj *var) { #if HAVE_PYTHON @@ -701,7 +701,6 @@ update_dynamic_varobj_children (struct varobj *var, if (update_children || var->dynamic->child_iter == NULL) { - delete var->dynamic->child_iter; var->dynamic->child_iter = varobj_get_iterator (var); varobj_clear_saved_item (var->dynamic); @@ -735,8 +734,7 @@ update_dynamic_varobj_children (struct varobj *var, if (item == NULL) { /* Iteration is done. Remove iterator from VAR. */ - delete var->dynamic->child_iter; - var->dynamic->child_iter = NULL; + var->dynamic->child_iter.reset (nullptr); break; } /* We don't want to push the extra child on any report list. */ @@ -1064,8 +1062,7 @@ install_visualizer (struct varobj_dynamic *var, PyObject *constructor, Py_XDECREF (var->pretty_printer); var->pretty_printer = visualizer; - delete var->child_iter; - var->child_iter = NULL; + var->child_iter.reset (nullptr); } /* Install the default visualizer for VAR. */ @@ -1875,7 +1872,6 @@ varobj::~varobj () } #endif - delete var->dynamic->child_iter; varobj_clear_saved_item (var->dynamic); if (is_root_p (var)) |