[review] Make windows_thread_info::name a unique_xmalloc_ptr
Commit Message
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-10-29 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(-)
Comments
Simon Marchi has posted comments on this change.
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/410
......................................................................
Patch Set 1: Code-Review+2
Pedro Alves has posted comments on this change.
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/410
......................................................................
Patch Set 2: Code-Review+2
@@ -1,5 +1,12 @@
2019-10-29 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-10-29 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>:
@@ -30,11 +30,6 @@
{
}
- ~windows_thread_info ()
- {
- xfree (name);
- }
-
DISABLE_COPY_AND_ASSIGN (windows_thread_info);
/* The Win32 thread identifier. */
@@ -68,7 +63,7 @@
bool reload_context = false;
/* The name of the thread, allocated by xmalloc. */
- char *name = nullptr;
+ gdb::unique_xmalloc_ptr<char> name;
};
#endif
@@ -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;
@@ -3000,7 +2999,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 ();
}