aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2020-12-11 09:33:36 -0700
committerTom Tromey <tom@tromey.com>2020-12-11 09:33:42 -0700
commit1345dee2805220742355b331934c2cdedf7669c6 (patch)
treee35f362c3cc938b7ea21f204393ae1f02a78456c
parent446d2c032d387a75020ecb41b5d89dd93158beb0 (diff)
downloadgdb-1345dee2805220742355b331934c2cdedf7669c6.zip
gdb-1345dee2805220742355b331934c2cdedf7669c6.tar.gz
gdb-1345dee2805220742355b331934c2cdedf7669c6.tar.bz2
Use gdbpy_ref in instantiate_pretty_printer
This changes instantiate_pretty_printer to use gdbpy_ref, removing a call to Py_DECREF. gdb/ChangeLog 2020-12-11 Tom Tromey <tom@tromey.com> * varobj.c (instantiate_pretty_printer): Use gdbpy_ref.
-rw-r--r--gdb/ChangeLog4
-rw-r--r--gdb/varobj.c11
2 files changed, 7 insertions, 8 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index f61cfda..90bfac7 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,9 @@
2020-12-11 Tom Tromey <tom@tromey.com>
+ * varobj.c (instantiate_pretty_printer): Use gdbpy_ref.
+
+2020-12-11 Tom Tromey <tom@tromey.com>
+
* varobj.c (varobj_clear_saved_item): Remove.
(update_dynamic_varobj_children): Update.
(varobj::~varobj): Don't call varobj_clear_saved_item.
diff --git a/gdb/varobj.c b/gdb/varobj.c
index 941c38c..ba0e135 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