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  <tom@tromey.com>

	* 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.
This commit is contained in:
Tom Tromey 2018-12-26 11:05:57 -07:00
parent 293bf1a719
commit 075c55e0cc
8 changed files with 40 additions and 57 deletions

View file

@ -143,12 +143,10 @@ objfpy_get_build_id (PyObject *self, void *closure)
if (build_id != NULL)
{
char *hex_form = make_hex_string (build_id->data, build_id->size);
PyObject *result;
gdb::unique_xmalloc_ptr<char> hex_form
(make_hex_string (build_id->data, build_id->size));
result = host_string_to_python_string (hex_form).release ();
xfree (hex_form);
return result;
return host_string_to_python_string (hex_form.get ()).release ();
}
Py_RETURN_NONE;