forked from Imagelibrary/binutils-gdb
Use gdb::unique_xmalloc_ptr when calling tilde_expand
This patch changes most sites calling tilde_expand to use gdb::unique_xmalloc_ptr, rather than a cleanup. It also changes scan_expression_with_cleanup to return a unique pointer, because the patch was already touching code in that area. Regression tested on the buildbot. ChangeLog 2017-08-05 Tom Tromey <tom@tromey.com> * compile/compile-object-load.c (compile_object_load): Use gdb::unique_xmalloc_ptr. * cli/cli-dump.c (scan_filename): Rename from scan_filename_with_cleanup. Change return type. (scan_expression): Rename from scan_expression_with_cleanup. Change return type. (dump_memory_to_file, dump_value_to_file, restore_command): Use gdb::unique_xmalloc_ptr. Update. * cli/cli-cmds.c (find_and_open_script): Use gdb::unique_xmalloc_ptr. * tracefile-tfile.c (tfile_open): Use gdb::unique_xmalloc_ptr. * symmisc.c (maintenance_print_symbols) (maintenance_print_msymbols): Use gdb::unique_xmalloc_ptr. * symfile.c (symfile_bfd_open, generic_load) (add_symbol_file_command, remove_symbol_file_command): Use gdb::unique_xmalloc_ptr. * source.c (openp): Use gdb::unique_xmalloc_ptr. * psymtab.c (maintenance_print_psymbols): Use gdb::unique_xmalloc_ptr. * corelow.c (core_open): Use gdb::unique_xmalloc_ptr. * breakpoint.c (save_breakpoints): Use gdb::unique_xmalloc_ptr. * solib.c (solib_map_sections): Use gdb::unique_xmalloc_ptr. (reload_shared_libraries_1): Likewise.
This commit is contained in:
@@ -15478,7 +15478,6 @@ save_breakpoints (char *filename, int from_tty,
|
||||
{
|
||||
struct breakpoint *tp;
|
||||
int any = 0;
|
||||
struct cleanup *cleanup;
|
||||
int extra_trace_bits = 0;
|
||||
|
||||
if (filename == 0 || *filename == 0)
|
||||
@@ -15512,14 +15511,13 @@ save_breakpoints (char *filename, int from_tty,
|
||||
return;
|
||||
}
|
||||
|
||||
filename = tilde_expand (filename);
|
||||
cleanup = make_cleanup (xfree, filename);
|
||||
gdb::unique_xmalloc_ptr<char> expanded_filename (tilde_expand (filename));
|
||||
|
||||
stdio_file fp;
|
||||
|
||||
if (!fp.open (filename, "w"))
|
||||
if (!fp.open (expanded_filename.get (), "w"))
|
||||
error (_("Unable to open file '%s' for saving (%s)"),
|
||||
filename, safe_strerror (errno));
|
||||
expanded_filename.get (), safe_strerror (errno));
|
||||
|
||||
if (extra_trace_bits)
|
||||
save_trace_state_variables (&fp);
|
||||
@@ -15587,8 +15585,7 @@ save_breakpoints (char *filename, int from_tty,
|
||||
fp.printf ("set default-collect %s\n", default_collect);
|
||||
|
||||
if (from_tty)
|
||||
printf_filtered (_("Saved to file '%s'.\n"), filename);
|
||||
do_cleanups (cleanup);
|
||||
printf_filtered (_("Saved to file '%s'.\n"), expanded_filename.get ());
|
||||
}
|
||||
|
||||
/* The `save breakpoints' command. */
|
||||
|
||||
Reference in New Issue
Block a user