Use gdbpy_ref in gdbpy_inferiors

This changes gdbpy_inferiors to use gdbpy_ref.

2017-01-10  Tom Tromey  <tom@tromey.com>

	* python/py-inferior.c (gdbpy_inferiors): Use gdbpy_ref.
This commit is contained in:
Tom Tromey 2016-11-06 21:23:31 -07:00
parent 80bd970a4b
commit f59fe7f8e3
2 changed files with 9 additions and 13 deletions

View file

@ -477,22 +477,14 @@ build_inferior_list (struct inferior *inf, void *arg)
PyObject *
gdbpy_inferiors (PyObject *unused, PyObject *unused2)
{
PyObject *list, *tuple;
list = PyList_New (0);
if (!list)
gdbpy_ref list (PyList_New (0));
if (list == NULL)
return NULL;
if (iterate_over_inferiors (build_inferior_list, list))
{
Py_DECREF (list);
return NULL;
}
if (iterate_over_inferiors (build_inferior_list, list.get ()))
return NULL;
tuple = PyList_AsTuple (list);
Py_DECREF (list);
return tuple;
return PyList_AsTuple (list.get ());
}
/* Membuf and memory manipulation. */