From patchwork Mon Oct 14 16:15:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 34945 Received: (qmail 123739 invoked by alias); 14 Oct 2019 16:15:55 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 123567 invoked by uid 89); 14 Oct 2019 16:15:48 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=management, HContent-Transfer-Encoding:8bit X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 14 Oct 2019 16:15:47 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 58BBD5604D; Mon, 14 Oct 2019 12:15:25 -0400 (EDT) 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 tTEnP-7qcLKm; Mon, 14 Oct 2019 12:15:25 -0400 (EDT) Received: from murgatroyd.Home (174-29-53-230.hlrn.qwest.net [174.29.53.230]) (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 0566056043; Mon, 14 Oct 2019 12:15:24 -0400 (EDT) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 7/9] Make windows_thread_info::name a unique_xmalloc_ptr Date: Mon, 14 Oct 2019 10:15:18 -0600 Message-Id: <20191014161520.13150-8-tromey@adacore.com> In-Reply-To: <20191014161520.13150-1-tromey@adacore.com> References: <20191014161520.13150-1-tromey@adacore.com> MIME-Version: 1.0 This changes windows_thread_info::name to be a unique_xmalloc_ptr, removing some manual memory management. 2019-10-14 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 0cfc0716f26..06c6486c0c0 100644 --- a/gdb/nat/windows-nat.h +++ b/gdb/nat/windows-nat.h @@ -30,11 +30,6 @@ struct windows_thread_info { } - ~windows_thread_info () - { - xfree (name); - } - DISABLE_COPY_AND_ASSIGN (windows_thread_info); /* The Win32 thread identifier. */ @@ -68,7 +63,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 b38ff402cb5..3a526e504e4 100644 --- a/gdb/windows-nat.c +++ b/gdb/windows-nat.c @@ -1261,8 +1261,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; @@ -3000,7 +2999,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 (); }