diff options
author | Simon Marchi <simon.marchi@ericsson.com> | 2018-08-07 17:43:08 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@ericsson.com> | 2018-08-07 17:43:08 -0400 |
commit | 528e15722bf67d126e17218708c0314bcfadbf6a (patch) | |
tree | 8b17bb0ea9569e150917b27be97b3ecfdc96fe62 /gdb/dwarf2read.c | |
parent | 96d68bd48c77fa44e517c3380ee8f224cbce00e5 (diff) | |
download | gdb-528e15722bf67d126e17218708c0314bcfadbf6a.zip gdb-528e15722bf67d126e17218708c0314bcfadbf6a.tar.gz gdb-528e15722bf67d126e17218708c0314bcfadbf6a.tar.bz2 |
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.
Diffstat (limited to 'gdb/dwarf2read.c')
-rw-r--r-- | gdb/dwarf2read.c | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index a758212..e4b621d 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -7757,19 +7757,17 @@ create_type_unit_group (struct dwarf2_cu *cu, sect_offset line_offset_struct) { unsigned int line_offset = to_underlying (line_offset_struct); struct partial_symtab *pst; - char *name; + std::string name; /* Give the symtab a useful name for debug purposes. */ if ((line_offset & NO_STMT_LIST_TYPE_UNIT_PSYMTAB) != 0) - name = xstrprintf ("<type_units_%d>", - (line_offset & ~NO_STMT_LIST_TYPE_UNIT_PSYMTAB)); + name = string_printf ("<type_units_%d>", + (line_offset & ~NO_STMT_LIST_TYPE_UNIT_PSYMTAB)); else - name = xstrprintf ("<type_units_at_0x%x>", line_offset); + name = string_printf ("<type_units_at_0x%x>", line_offset); - pst = create_partial_symtab (per_cu, name); + pst = create_partial_symtab (per_cu, name.c_str ()); pst->anonymous = 1; - - xfree (name); } tu_group->hash.dwo_unit = cu->dwo_unit; @@ -21844,15 +21842,15 @@ build_error_marker_type (struct dwarf2_cu *cu, struct die_info *die) struct dwarf2_per_objfile *dwarf2_per_objfile = cu->per_cu->dwarf2_per_objfile; struct objfile *objfile = dwarf2_per_objfile->objfile; - char *message, *saved; + char *saved; - message = xstrprintf (_("<unknown type in %s, CU %s, DIE %s>"), - objfile_name (objfile), - sect_offset_str (cu->header.sect_off), - sect_offset_str (die->sect_off)); + std::string message + = string_printf (_("<unknown type in %s, CU %s, DIE %s>"), + objfile_name (objfile), + sect_offset_str (cu->header.sect_off), + sect_offset_str (die->sect_off)); saved = (char *) obstack_copy0 (&objfile->objfile_obstack, - message, strlen (message)); - xfree (message); + message.c_str (), message.length ()); return init_type (objfile, TYPE_CODE_ERROR, 0, saved); } |