From e83e4e24021acb4b095b1e8a45a51c2ea088a1ed Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Tue, 27 Mar 2018 14:31:10 -0600 Subject: 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 * 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) : Update. Remove alloca. * ada-lang.c (ada_main_name): Update. --- gdb/solib-dsbt.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'gdb/solib-dsbt.c') diff --git a/gdb/solib-dsbt.c b/gdb/solib-dsbt.c index d038ccc..b3b66ba 100644 --- a/gdb/solib-dsbt.c +++ b/gdb/solib-dsbt.c @@ -696,7 +696,7 @@ dsbt_current_sos (void) if (dsbt_index != 0) { int errcode; - char *name_buf; + gdb::unique_xmalloc_ptr name_buf; struct int_elf32_dsbt_loadmap *loadmap; struct so_list *sop; CORE_ADDR addr; @@ -727,11 +727,10 @@ dsbt_current_sos (void) { if (solib_dsbt_debug) fprintf_unfiltered (gdb_stdlog, "current_sos: name = %s\n", - name_buf); + name_buf.get ()); - strncpy (sop->so_name, name_buf, SO_NAME_MAX_PATH_SIZE - 1); + strncpy (sop->so_name, name_buf.get (), SO_NAME_MAX_PATH_SIZE - 1); sop->so_name[SO_NAME_MAX_PATH_SIZE - 1] = '\0'; - xfree (name_buf); strcpy (sop->so_original_name, sop->so_name); } -- cgit v1.1