This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFA 07/14] Use gdbpy_reference in gdbpy_breakpoints


This changes gdbpy_breakpoints to use gdbpy_reference.

2016-11-06  Tom Tromey  <tom@tromey.com>

	* python/py-breakpoint.c (gdbpy_breakpoints): Use gdbpy_reference.
---
 gdb/ChangeLog              |  4 ++++
 gdb/python/py-breakpoint.c | 18 +++++-------------
 2 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 164b568..53f2e5f 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,9 @@
 2016-11-06  Tom Tromey  <tom@tromey.com>
 
+	* python/py-breakpoint.c (gdbpy_breakpoints): Use gdbpy_reference.
+
+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>
diff --git a/gdb/python/py-breakpoint.c b/gdb/python/py-breakpoint.c
index 656b13a..f9fbc06 100644
--- a/gdb/python/py-breakpoint.c
+++ b/gdb/python/py-breakpoint.c
@@ -763,28 +763,20 @@ build_bp_list (struct breakpoint *b, void *arg)
 PyObject *
 gdbpy_breakpoints (PyObject *self, PyObject *args)
 {
-  PyObject *list, *tuple;
-
   if (bppy_live == 0)
     return PyTuple_New (0);
 
-  list = PyList_New (0);
-  if (!list)
+  gdbpy_reference list (PyList_New (0));
+  if (list == NULL)
     return NULL;
 
   /* If iterate_over_breakpoints returns non NULL it signals an error
      condition.  In that case abandon building the list and return
      NULL.  */
-  if (iterate_over_breakpoints (build_bp_list, list) != NULL)
-    {
-      Py_DECREF (list);
-      return NULL;
-    }
-
-  tuple = PyList_AsTuple (list);
-  Py_DECREF (list);
+  if (iterate_over_breakpoints (build_bp_list, list.get ()) != NULL)
+    return NULL;
 
-  return tuple;
+  return PyList_AsTuple (list.get ());
 }
 
 /* Call the "stop" method (if implemented) in the breakpoint
-- 
2.7.4


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]