diff options
author | Tom Tromey <tom@tromey.com> | 2017-01-11 16:28:43 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2017-02-10 12:24:32 -0700 |
commit | 88b6faea9953505e9e8a7a77995c7db5dfb6ac19 (patch) | |
tree | 8c37cbea07dded189647be98286894aa9e172579 /gdb/python/py-frame.c | |
parent | 7780f18678aeb553778633aeb50f41694f55bf27 (diff) | |
download | gdb-88b6faea9953505e9e8a7a77995c7db5dfb6ac19.zip gdb-88b6faea9953505e9e8a7a77995c7db5dfb6ac19.tar.gz gdb-88b6faea9953505e9e8a7a77995c7db5dfb6ac19.tar.bz2 |
Use gdbpy_ref to simplify some logic
This uses the new gdbpy_ref template to simplify logic in various
parts of the Python layer; for example removing repeated error code or
removing gotos.
gdb/ChangeLog
2017-02-10 Tom Tromey <tom@tromey.com>
* python/py-cmd.c (cmdpy_destroyer): Use gdbpy_ref.
* python/py-breakpoint.c (gdbpy_breakpoint_deleted): Use
gdbpy_ref.
* python/py-type.c (field_new): Use gdbpy_ref.
* python/py-symtab.c (symtab_and_line_to_sal_object): Use
gdbpy_ref.
* python/py-progspace.c (pspy_new): Use gdbpy_ref.
(py_free_pspace): Likewise.
(pspace_to_pspace_object): Likewise.
* python/py-objfile.c (objfpy_new): Use gdbpy_ref.
(py_free_objfile): Likewise.
(objfile_to_objfile_object): Likewise.
* python/py-inferior.c (delete_thread_object): Use
gdbpy_ref.
(infpy_read_memory): Likewise.
(py_free_inferior): Likewise.
* python/py-evtregistry.c (create_eventregistry_object): Use
gdbpy_ref.
* python/py-event.c (create_event_object): Use gdbpy_ref.
Diffstat (limited to 'gdb/python/py-frame.c')
-rw-r--r-- | gdb/python/py-frame.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/gdb/python/py-frame.c b/gdb/python/py-frame.c index 8f5ddd0..891f44e 100644 --- a/gdb/python/py-frame.c +++ b/gdb/python/py-frame.c @@ -28,6 +28,7 @@ #include "symfile.h" #include "objfiles.h" #include "user-regs.h" +#include "py-ref.h" typedef struct { PyObject_HEAD @@ -359,9 +360,8 @@ frapy_function (PyObject *self, PyObject *args) PyObject * frame_info_to_frame_object (struct frame_info *frame) { - frame_object *frame_obj; - - frame_obj = PyObject_New (frame_object, &frame_object_type); + gdbpy_ref<frame_object> frame_obj (PyObject_New (frame_object, + &frame_object_type)); if (frame_obj == NULL) return NULL; @@ -387,13 +387,12 @@ frame_info_to_frame_object (struct frame_info *frame) } CATCH (except, RETURN_MASK_ALL) { - Py_DECREF (frame_obj); gdbpy_convert_exception (except); return NULL; } END_CATCH - return (PyObject *) frame_obj; + return (PyObject *) frame_obj.release (); } /* Implementation of gdb.Frame.older (self) -> gdb.Frame. |