Replace some uses of xstrprintf with string_printf

This patch replaces some simple uses of xstrprintf with with
string_printf, removing the need to do manual memory freeing.

The change in ada-lang.c fixes an apparent memory leak.

Regtested on the buildbot.

gdb/ChangeLog:

	* common/filestuff.h (gdb_fopen_cloexec): New overload.
	(gdb_open_cloexec): Likewise.
	* nat/linux-osdata.c (command_from_pid): Use string_printf.
	(commandline_from_pid): Likewise.
	(linux_xfer_osdata_threads): Likewise.
	(linux_xfer_osdata_fds): Likewise.
	* ada-lang.c (is_package_name): Likewise.
	* auxv.c (procfs_xfer_auxv): Likewise.
	* breakpoint.c (print_one_breakpoint_location): Use
	uiout::field_fmt.
	(print_one_catch_solib): Use string_printf.
	* coff-pe-read.c (add_pe_exported_sym): Likewise.
	(add_pe_forwarded_sym): Likewise.
	* dwarf2read.c (create_type_unit_group): Likewise.
	(build_error_marker_type): Likewise.
	* infcall.c (get_function_name): Likewise.
	* valprint.c (print_converted_chars_to_obstack): Likewise.
	* xtensa-tdep.c (xtensa_register_type): Likewise.
This commit is contained in:
Simon Marchi
2018-08-07 17:43:08 -04:00
parent 96d68bd48c
commit 528e15722b
11 changed files with 99 additions and 83 deletions

View File

@@ -5205,8 +5205,6 @@ is_package_name (const char *name)
to NAME not existing in our list of symbols. There is only one
small complication with library-level functions (see below). */
char *fun_name;
/* If it is a function that has not been defined at library level,
then we should be able to look it up in the symbols. */
if (standard_lookup (name, NULL, VAR_DOMAIN) != NULL)
@@ -5220,9 +5218,9 @@ is_package_name (const char *name)
if (strstr (name, "__") != NULL)
return 0;
fun_name = xstrprintf ("_ada_%s", name);
std::string fun_name = string_printf ("_ada_%s", name);
return (standard_lookup (fun_name, NULL, VAR_DOMAIN) == NULL);
return (standard_lookup (fun_name.c_str (), NULL, VAR_DOMAIN) == NULL);
}
/* Return nonzero if SYM corresponds to a renaming entity that is