From 075c55e0cc0a68eeab777027213c2f545618e844 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Wed, 26 Dec 2018 11:05:57 -0700 Subject: Remove more calls to xfree from Python This changes the Python code to remove some more calls to xfree, in favor of self-managing data structures. Tested on x86-64 Fedora 28. gdb/ChangeLog 2018-12-27 Tom Tromey * python/python.c (python_interactive_command): Use std::string. (gdbpy_parameter): Likewise. * python/py-utils.c (unicode_to_encoded_string): Update comment. * python/py-symtab.c (salpy_str): Use PyString_FromFormat. * python/py-record-btrace.c (recpy_bt_insn_data): Use byte_vector. * python/py-objfile.c (objfpy_get_build_id): Use unique_xmalloc_ptr. * python/py-inferior.c (infpy_read_memory): Use unique_xmalloc_ptr. * python/py-cmd.c (gdbpy_parse_command_name): Use std::string. --- gdb/python/py-symtab.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'gdb/python/py-symtab.c') diff --git a/gdb/python/py-symtab.c b/gdb/python/py-symtab.c index 4b29299..d1326e3 100644 --- a/gdb/python/py-symtab.c +++ b/gdb/python/py-symtab.c @@ -220,10 +220,8 @@ stpy_get_linetable (PyObject *self, PyObject *args) static PyObject * salpy_str (PyObject *self) { - char *s; const char *filename; sal_object *sal_obj; - PyObject *result; struct symtab_and_line *sal = NULL; SALPY_REQUIRE_VALID (self, sal); @@ -232,13 +230,8 @@ salpy_str (PyObject *self) filename = (sal_obj->symtab == (symtab_object *) Py_None) ? "" : symtab_to_filename_for_display (sal_obj->symtab->symtab); - s = xstrprintf ("symbol and line for %s, line %d", filename, - sal->line); - - result = PyString_FromString (s); - xfree (s); - - return result; + return PyString_FromFormat ("symbol and line for %s, line %d", filename, + sal->line); } static void -- cgit v1.1