This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[RFA 10/14] Use gdbpy_reference in call_doc_function
- From: Tom Tromey <tom at tromey dot com>
- To: gdb-patches at sourceware dot org
- Cc: Tom Tromey <tom at tromey dot com>
- Date: Sun, 6 Nov 2016 22:47:32 -0700
- Subject: [RFA 10/14] Use gdbpy_reference in call_doc_function
- Authentication-results: sourceware.org; auth=none
- References: <1478497656-11832-1-git-send-email-tom@tromey.com>
This changes call_doc_function to use gdbpy_reference.
2016-11-06 Tom Tromey <tom@tromey.com>
* python/py-param.c (call_doc_function): Use gdbpy_reference.
---
gdb/ChangeLog | 4 ++++
gdb/python/py-param.c | 11 +++++------
2 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 9aa7008..9544515 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,9 @@
2016-11-06 Tom Tromey <tom@tromey.com>
+ * python/py-param.c (call_doc_function): Use gdbpy_reference.
+
+2016-11-06 Tom Tromey <tom@tromey.com>
+
* python/py-linetable.c (build_line_table_tuple_from_pcs)
(ltpy_get_all_source_lines): Use gdbpy_reference.
diff --git a/gdb/python/py-param.c b/gdb/python/py-param.c
index 3604f9f..dae2f7b 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
@@ -331,15 +332,14 @@ static char *
call_doc_function (PyObject *obj, PyObject *method, PyObject *arg)
{
char *data = NULL;
- PyObject *result = PyObject_CallMethodObjArgs (obj, method, arg, NULL);
+ gdbpy_reference 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;
}
@@ -347,7 +347,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;
}
--
2.7.4