From 528e15722bf67d126e17218708c0314bcfadbf6a Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Tue, 7 Aug 2018 17:43:08 -0400 Subject: 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. --- gdb/xtensa-tdep.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'gdb/xtensa-tdep.c') diff --git a/gdb/xtensa-tdep.c b/gdb/xtensa-tdep.c index 60e34c3..7c0d8c1 100644 --- a/gdb/xtensa-tdep.c +++ b/gdb/xtensa-tdep.c @@ -319,15 +319,14 @@ xtensa_register_type (struct gdbarch *gdbarch, int regnum) if (tp == NULL) { - char *name = xstrprintf ("int%d", size * 8); + std::string name = string_printf ("int%d", size * 8); tp = XNEW (struct ctype_cache); tp->next = tdep->type_entries; tdep->type_entries = tp; tp->size = size; tp->virtual_type - = arch_integer_type (gdbarch, size * 8, 1, name); - xfree (name); + = arch_integer_type (gdbarch, size * 8, 1, name.c_str ()); } reg->ctype = tp->virtual_type; -- cgit v1.1