aboutsummaryrefslogtreecommitdiff
path: root/gdb/python
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2016-11-06 21:51:20 -0700
committerTom Tromey <tom@tromey.com>2017-01-10 19:13:38 -0700
commit37fce74fb42f45ec340962170a4b297beede733a (patch)
treebd162c1e80fece5f14f3c65b9f2ba3564ea6f542 /gdb/python
parent53a0cca3bd0f6ae80b2d6fc34b2873046965c7f0 (diff)
downloadgdb-37fce74fb42f45ec340962170a4b297beede733a.zip
gdb-37fce74fb42f45ec340962170a4b297beede733a.tar.gz
gdb-37fce74fb42f45ec340962170a4b297beede733a.tar.bz2
Use gdbpy_ref in gdbpy_lookup_symbol
This changes gdbpy_lookup_symbol to use gdbpy_ref. 2017-01-10 Tom Tromey <tom@tromey.com> * python/py-symbol.c (gdbpy_lookup_symbol): Use gdbpy_ref.
Diffstat (limited to 'gdb/python')
-rw-r--r--gdb/python/py-symbol.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/gdb/python/py-symbol.c b/gdb/python/py-symbol.c
index 156a313..34e953f 100644
--- a/gdb/python/py-symbol.c
+++ b/gdb/python/py-symbol.c
@@ -23,6 +23,7 @@
#include "symtab.h"
#include "python-internal.h"
#include "objfiles.h"
+#include "py-ref.h"
typedef struct sympy_symbol_object {
PyObject_HEAD
@@ -374,7 +375,7 @@ gdbpy_lookup_symbol (PyObject *self, PyObject *args, PyObject *kw)
const char *name;
static char *keywords[] = { "name", "block", "domain", NULL };
struct symbol *symbol = NULL;
- PyObject *block_obj = NULL, *ret_tuple, *sym_obj, *bool_obj;
+ PyObject *block_obj = NULL, *sym_obj, *bool_obj;
const struct block *block = NULL;
if (! PyArg_ParseTupleAndKeywords (args, kw, "s|O!i", keywords, &name,
@@ -410,31 +411,28 @@ gdbpy_lookup_symbol (PyObject *self, PyObject *args, PyObject *kw)
}
END_CATCH
- ret_tuple = PyTuple_New (2);
- if (!ret_tuple)
+ gdbpy_ref ret_tuple (PyTuple_New (2));
+ if (ret_tuple == NULL)
return NULL;
if (symbol)
{
sym_obj = symbol_to_symbol_object (symbol);
if (!sym_obj)
- {
- Py_DECREF (ret_tuple);
- return NULL;
- }
+ return NULL;
}
else
{
sym_obj = Py_None;
Py_INCREF (Py_None);
}
- PyTuple_SET_ITEM (ret_tuple, 0, sym_obj);
+ PyTuple_SET_ITEM (ret_tuple.get (), 0, sym_obj);
bool_obj = (is_a_field_of_this.type != NULL) ? Py_True : Py_False;
Py_INCREF (bool_obj);
- PyTuple_SET_ITEM (ret_tuple, 1, bool_obj);
+ PyTuple_SET_ITEM (ret_tuple.get (), 1, bool_obj);
- return ret_tuple;
+ return ret_tuple.release ();
}
/* Implementation of