Change varobj_iter::next to return unique_ptr
This changes varobj_iter::next to return a unique_ptr. This fits in with the ongoing theme of trying to express these ownership transfers via the type system. gdb/ChangeLog 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 type. (py_varobj_iter::next): Likewise.
This commit is contained in:
parent
54746ce37a
commit
60ee72f6d3
4 changed files with 16 additions and 10 deletions
10
gdb/varobj.c
10
gdb/varobj.c
|
@ -719,12 +719,12 @@ update_dynamic_varobj_children (struct varobj *var,
|
|||
are more children. */
|
||||
for (; to < 0 || i < to + 1; ++i)
|
||||
{
|
||||
varobj_item *item;
|
||||
std::unique_ptr<varobj_item> item;
|
||||
|
||||
/* See if there was a leftover from last time. */
|
||||
if (var->dynamic->saved_item != NULL)
|
||||
{
|
||||
item = var->dynamic->saved_item;
|
||||
item = std::unique_ptr<varobj_item> (var->dynamic->saved_item);
|
||||
var->dynamic->saved_item = NULL;
|
||||
}
|
||||
else
|
||||
|
@ -753,13 +753,11 @@ update_dynamic_varobj_children (struct varobj *var,
|
|||
can_mention ? newobj : NULL,
|
||||
can_mention ? unchanged : NULL,
|
||||
can_mention ? cchanged : NULL, i,
|
||||
item);
|
||||
|
||||
delete item;
|
||||
item.get ());
|
||||
}
|
||||
else
|
||||
{
|
||||
var->dynamic->saved_item = item;
|
||||
var->dynamic->saved_item = item.release ();
|
||||
|
||||
/* We want to truncate the child list just before this
|
||||
element. */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue