[PATCH 10/11] Use gdbpy_ref in instantiate_pretty_printer
Tom Tromey
tom@tromey.com
Sat Oct 24 21:08:55 GMT 2020
This changes instantiate_pretty_printer to use gdbpy_ref, removing a
call to Py_DECREF.
gdb/ChangeLog
2020-10-24 Tom Tromey <tom@tromey.com>
* varobj.c (instantiate_pretty_printer): Use gdbpy_ref.
---
gdb/ChangeLog | 4 ++++
gdb/varobj.c | 11 +++--------
2 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/gdb/varobj.c b/gdb/varobj.c
index 8b02eb338b4..be161eb0208 100644
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -459,16 +459,11 @@ varobj_delete (struct varobj *var, bool only_children)
static PyObject *
instantiate_pretty_printer (PyObject *constructor, struct value *value)
{
- PyObject *val_obj = NULL;
- PyObject *printer;
-
- val_obj = value_to_value_object (value);
- if (! val_obj)
+ gdbpy_ref<> val_obj (value_to_value_object (value));
+ if (val_obj == nullptr)
return NULL;
- printer = PyObject_CallFunctionObjArgs (constructor, val_obj, NULL);
- Py_DECREF (val_obj);
- return printer;
+ return PyObject_CallFunctionObjArgs (constructor, val_obj.get (), NULL);
}
#endif
--
2.17.2
More information about the Gdb-patches
mailing list