+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.
+
2020-12-11 Tom Tromey <tom@tromey.com>
* varobj.c (struct varobj_dynamic) <saved_item>: Now unique_ptr.
/* Return a new pretty-printed varobj iterator suitable to iterate
over VAR's children. */
-struct varobj_iter *
+std::unique_ptr<varobj_iter>
py_varobj_get_iterator (struct varobj *var, PyObject *printer)
{
gdbpy_enter_varobj enter_py (var);
error (_("Could not get children iterator"));
}
- return new py_varobj_iter (var, std::move (iter));
+ return std::unique_ptr<varobj_iter> (new py_varobj_iter (var,
+ std::move (iter)));
}
/* 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
/* 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
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);
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. */
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. */
}
#endif
- delete var->dynamic->child_iter;
varobj_clear_saved_item (var->dynamic);
if (is_root_p (var))