Use gdbpy_ref in gdbpy_breakpoints
authorTom Tromey <tom@tromey.com>
Mon, 7 Nov 2016 04:25:22 +0000 (21:25 -0700)
committerTom Tromey <tom@tromey.com>
Wed, 11 Jan 2017 02:13:33 +0000 (19:13 -0700)
This changes gdbpy_breakpoints to use gdbpy_ref.

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

* python/py-breakpoint.c (gdbpy_breakpoints): Use gdbpy_ref.

gdb/ChangeLog
gdb/python/py-breakpoint.c

index 330718af4f82abff861642961f7da7973630aa3e..e2cf5b9f5efd450d9c954be6105c391a5a481d29 100644 (file)
@@ -1,3 +1,7 @@
+2017-01-10  Tom Tromey  <tom@tromey.com>
+
+       * python/py-breakpoint.c (gdbpy_breakpoints): Use gdbpy_ref.
+
 2017-01-10  Tom Tromey  <tom@tromey.com>
 
        * python/py-inferior.c (gdbpy_inferiors): Use gdbpy_ref.
index c8847ffe08a7867b941393127a7ba4383cc20bf6..eedb697786c4967ed5c3db76ca1adf41e74df2fe 100644 (file)
@@ -762,28 +762,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_ref 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
This page took 0.027817 seconds and 4 git commands to generate.