From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id BD42C3945060; Wed, 8 Apr 2020 20:49:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BD42C3945060 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Tom Tromey To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Make windows_thread_info::name a unique_xmalloc_ptr X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: 62fe396b1cba6b0c3d06b758d9f8254c6d538ad8 X-Git-Newrev: 2950fdf7423a404f6ebc691606d04917fd68228a Message-Id: <20200408204954.BD42C3945060@sourceware.org> Date: Wed, 8 Apr 2020 20:49:54 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Apr 2020 20:49:54 -0000 https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=2950fdf7423a404f6ebc691606d04917fd68228a commit 2950fdf7423a404f6ebc691606d04917fd68228a Author: Tom Tromey Date: Wed Apr 8 14:33:35 2020 -0600 Make windows_thread_info::name a unique_xmalloc_ptr This changes windows_thread_info::name to be a unique_xmalloc_ptr, removing some manual memory management. gdb/ChangeLog 2020-04-08 Tom Tromey * windows-nat.c (handle_exception) (windows_nat_target::thread_name): Update. * nat/windows-nat.h (windows_thread_info): Remove destructor. : Now unique_xmalloc_ptr. Diff: --- gdb/ChangeLog | 7 +++++++ gdb/nat/windows-nat.h | 7 +------ gdb/windows-nat.c | 5 ++--- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 6fce48c09a0..a7ffec78764 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,10 @@ +2020-04-08 Tom Tromey + + * windows-nat.c (handle_exception) + (windows_nat_target::thread_name): Update. + * nat/windows-nat.h (windows_thread_info): Remove destructor. + : Now unique_xmalloc_ptr. + 2020-04-08 Tom Tromey * windows-nat.c (thread_rec) diff --git a/gdb/nat/windows-nat.h b/gdb/nat/windows-nat.h index 27fd7ed19da..543de895e77 100644 --- a/gdb/nat/windows-nat.h +++ b/gdb/nat/windows-nat.h @@ -32,11 +32,6 @@ struct windows_thread_info { } - ~windows_thread_info () - { - xfree (name); - } - DISABLE_COPY_AND_ASSIGN (windows_thread_info); /* The Win32 thread identifier. */ @@ -77,7 +72,7 @@ struct windows_thread_info bool reload_context = false; /* The name of the thread, allocated by xmalloc. */ - char *name = nullptr; + gdb::unique_xmalloc_ptr name; }; #endif diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c index b7f21cb741d..7fbc9a4d27d 100644 --- a/gdb/windows-nat.c +++ b/gdb/windows-nat.c @@ -1414,8 +1414,7 @@ handle_exception (struct target_waitstatus *ourstatus) if (thread_name_len > 0) { thread_name.get ()[thread_name_len - 1] = '\0'; - xfree (named_thread->name); - named_thread->name = thread_name.release (); + named_thread->name = std::move (thread_name); } } ourstatus->value.sig = GDB_SIGNAL_TRAP; @@ -3394,7 +3393,7 @@ windows_nat_target::get_ada_task_ptid (long lwp, long thread) const char * windows_nat_target::thread_name (struct thread_info *thr) { - return thread_rec (thr->ptid.tid (), 0)->name; + return thread_rec (thr->ptid.tid (), 0)->name.get (); }