Change target_read_string to use unique_xmalloc_ptr

This changes the out parameter of target_read_string to be a
unique_xmalloc_ptr.  This avoids a cleanup and sets the stage for more
cleanup removals.

This patch also removes a seemingly needless alloca from
print_subexp_standard.

gdb/ChangeLog
2018-03-30  Tom Tromey  <tom@tromey.com>

	* windows-nat.c (handle_output_debug_string, handle_exception):
	Update.
	* target.h (target_read_string): Update.
	* target.c (target_read_string): Change "string" to
	unique_xmalloc_ptr.
	* solib-svr4.c (open_symbol_file_object, svr4_read_so_list):
	Update.
	* solib-frv.c (frv_current_sos): Update.
	* solib-dsbt.c (dsbt_current_sos): Update.
	* solib-darwin.c (darwin_current_sos): Update.
	* linux-thread-db.c (inferior_has_bug): Update.
	* expprint.c (print_subexp_standard) <case OP_OBJC_MSGCALL>:
	Update.  Remove alloca.
	* ada-lang.c (ada_main_name): Update.
This commit is contained in:
Tom Tromey 2018-03-27 14:31:10 -06:00
parent 263db9a1f4
commit e83e4e2402
11 changed files with 55 additions and 49 deletions

View file

@ -913,7 +913,7 @@ char *
ada_main_name (void)
{
struct bound_minimal_symbol msym;
static char *main_program_name = NULL;
static gdb::unique_xmalloc_ptr<char> main_program_name;
/* For Ada, the name of the main procedure is stored in a specific
string constant, generated by the binder. Look for that symbol,
@ -931,13 +931,12 @@ ada_main_name (void)
if (main_program_name_addr == 0)
error (_("Invalid address for Ada main program name."));
xfree (main_program_name);
target_read_string (main_program_name_addr, &main_program_name,
1024, &err_code);
if (err_code != 0)
return NULL;
return main_program_name;
return main_program_name.get ();
}
/* The main procedure doesn't seem to be in Ada. */