This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[RFA 06/14] Use gdbpy_reference in gdbpy_inferiors
- From: Tom Tromey <tom at tromey dot com>
- To: gdb-patches at sourceware dot org
- Cc: Tom Tromey <tom at tromey dot com>
- Date: Sun, 6 Nov 2016 22:47:28 -0700
- Subject: [RFA 06/14] Use gdbpy_reference in gdbpy_inferiors
- Authentication-results: sourceware.org; auth=none
- References: <1478497656-11832-1-git-send-email-tom@tromey.com>
This changes gdbpy_inferiors to use gdbpy_reference.
2016-11-06 Tom Tromey <tom@tromey.com>
* python/py-inferior.c (gdbpy_inferiors): Use gdbpy_reference.
---
gdb/ChangeLog | 4 ++++
gdb/python/py-inferior.c | 18 +++++-------------
2 files changed, 9 insertions(+), 13 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 8271499..164b568 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,9 @@
2016-11-06 Tom Tromey <tom@tromey.com>
+ * python/py-inferior.c (gdbpy_inferiors): Use gdbpy_reference.
+
+2016-11-06 Tom Tromey <tom@tromey.com>
+
* python/py-function.c (convert_values_to_python, fnpy_init): Use
gdbpy_reference.
diff --git a/gdb/python/py-inferior.c b/gdb/python/py-inferior.c
index 8732b87..b343c0f 100644
--- a/gdb/python/py-inferior.c
+++ b/gdb/python/py-inferior.c
@@ -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_reference list (PyList_New (0));
+ if (list == NULL)
return NULL;
- if (iterate_over_inferiors (build_inferior_list, list))
- {
- Py_DECREF (list);
- return NULL;
- }
-
- tuple = PyList_AsTuple (list);
- Py_DECREF (list);
+ if (iterate_over_inferiors (build_inferior_list, list.get ()))
+ return NULL;
- return tuple;
+ return PyList_AsTuple (list.get ());
}
/* Membuf and memory manipulation. */
--
2.7.4