From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from rock.gnat.com (rock.gnat.com [205.232.38.15]) by sourceware.org (Postfix) with ESMTP id 8E05B3AAA068 for ; Fri, 13 Mar 2020 19:08:59 +0000 (GMT) Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 6B77B561B5; Fri, 13 Mar 2020 15:08:59 -0400 (EDT) X-Virus-Scanned: Debian amavisd-new at gnat.com Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id BRNsTtxzsBcW; Fri, 13 Mar 2020 15:08:59 -0400 (EDT) Received: from murgatroyd.Home (184-96-250-69.hlrn.qwest.net [184.96.250.69]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPSA id 2896A561B0; Fri, 13 Mar 2020 15:08:59 -0400 (EDT) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH v3 07/29] Make windows_thread_info::name a unique_xmalloc_ptr Date: Fri, 13 Mar 2020 13:08:33 -0600 Message-Id: <20200313190855.28662-8-tromey@adacore.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200313190855.28662-1-tromey@adacore.com> References: <20200313190855.28662-1-tromey@adacore.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-25.0 required=5.0 tests=GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Mar 2020 19:09:00 -0000 This changes windows_thread_info::name to be a unique_xmalloc_ptr, removing some manual memory management. gdb/ChangeLog 2020-03-13 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. --- 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/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 866afffa262..4fe5dfe7db0 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; @@ -3351,7 +3350,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 (); } -- 2.21.1