aboutsummaryrefslogtreecommitdiff
path: root/gdb/python/py-param.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2016-11-06 21:29:12 -0700
committerTom Tromey <tom@tromey.com>2017-01-10 19:13:35 -0700
commit1bb44c9f567c75355c1b4417d88cda959e82a3a3 (patch)
treee2bc3f34106aafc33a15bfe653504a12e7ef30a4 /gdb/python/py-param.c
parent87ce03fdc5a94f48fe62580410a099c0a0f68ee0 (diff)
downloadfsf-binutils-gdb-1bb44c9f567c75355c1b4417d88cda959e82a3a3.zip
fsf-binutils-gdb-1bb44c9f567c75355c1b4417d88cda959e82a3a3.tar.gz
fsf-binutils-gdb-1bb44c9f567c75355c1b4417d88cda959e82a3a3.tar.bz2
Use gdbpy_ref in call_doc_function
This changes call_doc_function to use gdbpy_ref. 2017-01-10 Tom Tromey <tom@tromey.com> * python/py-param.c (call_doc_function): Use gdbpy_ref.
Diffstat (limited to 'gdb/python/py-param.c')
-rw-r--r--gdb/python/py-param.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/gdb/python/py-param.c b/gdb/python/py-param.c
index 7c3223f..d9d8baa 100644
--- a/gdb/python/py-param.c
+++ b/gdb/python/py-param.c
@@ -27,6 +27,7 @@
#include "completer.h"
#include "language.h"
#include "arch-utils.h"
+#include "py-ref.h"
/* Parameter constants and their values. */
struct parm_constant
@@ -329,15 +330,14 @@ static gdb::unique_xmalloc_ptr<char>
call_doc_function (PyObject *obj, PyObject *method, PyObject *arg)
{
gdb::unique_xmalloc_ptr<char> data;
- PyObject *result = PyObject_CallMethodObjArgs (obj, method, arg, NULL);
+ gdbpy_ref result (PyObject_CallMethodObjArgs (obj, method, arg, NULL));
- if (! result)
+ if (result == NULL)
return NULL;
- if (gdbpy_is_string (result))
+ if (gdbpy_is_string (result.get ()))
{
- data = python_string_to_host_string (result);
- Py_DECREF (result);
+ data = python_string_to_host_string (result.get ());
if (! data)
return NULL;
}
@@ -345,7 +345,6 @@ call_doc_function (PyObject *obj, PyObject *method, PyObject *arg)
{
PyErr_SetString (PyExc_RuntimeError,
_("Parameter must return a string value."));
- Py_DECREF (result);
return NULL;
}