public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: "Tom Tromey (Code Review)" <gerrit@gnutoolchain-gerrit.osci.io>
To: Simon Marchi <simon.marchi@polymtl.ca>, gdb-patches@sourceware.org
Subject: [review v2] Make windows_thread_info::name a unique_xmalloc_ptr
Date: Tue, 26 Nov 2019 17:11:00 -0000	[thread overview]
Message-ID: <20191126171131.3284128174@gnutoolchain-gerrit.osci.io> (raw)
In-Reply-To: <gerrit.1572371871000.Ieb950249ddaf58ecc8faf98cc2b464d86c53fde3@gnutoolchain-gerrit.osci.io>

Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/410
......................................................................

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
2019-11-26  Tom Tromey  <tromey@adacore.com>

	* windows-nat.c (handle_exception)
	(windows_nat_target::thread_name): Update.
	* nat/windows-nat.h (windows_thread_info): Remove destructor.
	<name>: Now unique_xmalloc_ptr.

Change-Id: Ieb950249ddaf58ecc8faf98cc2b464d86c53fde3
---
M gdb/ChangeLog
M gdb/nat/windows-nat.h
M gdb/windows-nat.c
3 files changed, 10 insertions(+), 9 deletions(-)



diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index e48f650..621f890 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,12 @@
 2019-11-26  Tom Tromey  <tromey@adacore.com>
 
+	* windows-nat.c (handle_exception)
+	(windows_nat_target::thread_name): Update.
+	* nat/windows-nat.h (windows_thread_info): Remove destructor.
+	<name>: Now unique_xmalloc_ptr.
+
+2019-11-26  Tom Tromey  <tromey@adacore.com>
+
 	* windows-nat.c (thread_rec)
 	(windows_nat_target::fetch_registers): Update.
 	* nat/windows-nat.h (struct windows_thread_info) <suspended>:
diff --git a/gdb/nat/windows-nat.h b/gdb/nat/windows-nat.h
index e5d7e63..db21ca7 100644
--- a/gdb/nat/windows-nat.h
+++ b/gdb/nat/windows-nat.h
@@ -30,11 +30,6 @@
   {
   }
 
-  ~windows_thread_info ()
-  {
-    xfree (name);
-  }
-
   DISABLE_COPY_AND_ASSIGN (windows_thread_info);
 
   /* The Win32 thread identifier.  */
@@ -69,7 +64,7 @@
   bool reload_context = false;
 
   /* The name of the thread, allocated by xmalloc.  */
-  char *name = nullptr;
+  gdb::unique_xmalloc_ptr<char> name;
 };
 
 #endif
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index 4898fba..f283495 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -1261,8 +1261,7 @@
 	      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;
@@ -3001,7 +3000,7 @@
 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 ();
 }
 
 

-- 
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: Ieb950249ddaf58ecc8faf98cc2b464d86c53fde3
Gerrit-Change-Number: 410
Gerrit-PatchSet: 2
Gerrit-Owner: Tom Tromey <tromey@sourceware.org>
Gerrit-Reviewer: Simon Marchi <simon.marchi@polymtl.ca>
Gerrit-MessageType: newpatchset

  parent reply	other threads:[~2019-11-26 17:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-29 17:58 [review] " Tom Tromey (Code Review)
2019-10-31 19:06 ` Simon Marchi (Code Review)
2019-11-26 17:11 ` Tom Tromey (Code Review) [this message]
2019-11-29 18:01 ` [review v2] " Pedro Alves (Code Review)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191126171131.3284128174@gnutoolchain-gerrit.osci.io \
    --to=gerrit@gnutoolchain-gerrit.osci.io \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@polymtl.ca \
    --cc=tromey@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).