From c92aed165e8af79f51c5165f98f12389bb59a121 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Tue, 8 Nov 2016 15:26:45 +0000 Subject: Use ui_file_as_string in gdb/python/ gdb/ChangeLog: 2016-11-08 Pedro Alves * python/py-arch.c (archpy_disassemble): Use ui_file_as_string and std::string. * python/py-breakpoint.c (bppy_get_commands): Use ui_file_as_string and std::string. * python/py-frame.c (frapy_str): Likewise. * python/py-type.c (typy_str): Likewise. * python/py-unwind.c (unwind_infopy_str): Likewise. * python/py-value.c (valpy_str): Likewise. --- gdb/python/py-arch.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'gdb/python/py-arch.c') diff --git a/gdb/python/py-arch.c b/gdb/python/py-arch.c index 4a2dcbf..60cc5a9 100644 --- a/gdb/python/py-arch.c +++ b/gdb/python/py-arch.c @@ -198,7 +198,6 @@ archpy_disassemble (PyObject *self, PyObject *args, PyObject *kw) || (end_obj == NULL && count_obj == NULL && pc == start);) { int insn_len = 0; - char *as = NULL; struct ui_file *memfile = mem_fileopen (); PyObject *insn_dict = PyDict_New (); @@ -232,18 +231,20 @@ archpy_disassemble (PyObject *self, PyObject *args, PyObject *kw) } END_CATCH - as = ui_file_xstrdup (memfile, NULL); + std::string as = ui_file_as_string (memfile); + if (PyDict_SetItemString (insn_dict, "addr", gdb_py_long_from_ulongest (pc)) || PyDict_SetItemString (insn_dict, "asm", - PyString_FromString (*as ? as : "")) + PyString_FromString (!as.empty () + ? as.c_str () + : "")) || PyDict_SetItemString (insn_dict, "length", PyInt_FromLong (insn_len))) { Py_DECREF (result_list); ui_file_delete (memfile); - xfree (as); return NULL; } @@ -251,7 +252,6 @@ archpy_disassemble (PyObject *self, PyObject *args, PyObject *kw) pc += insn_len; i++; ui_file_delete (memfile); - xfree (as); } return result_list; -- cgit v1.1