aboutsummaryrefslogtreecommitdiff
path: root/gdb/infcmd.c
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@efficios.com>2020-06-25 14:44:13 -0400
committerSimon Marchi <simon.marchi@efficios.com>2020-06-25 14:44:35 -0400
commit277474eea03e0f77a9d37c69dfab3f0c41812348 (patch)
tree5e415b1644e846c6076f19f4864301301270fb1a /gdb/infcmd.c
parentd73be6116811aeaedd1863c2597ede78be3cf4e5 (diff)
downloadgdb-277474eea03e0f77a9d37c69dfab3f0c41812348.zip
gdb-277474eea03e0f77a9d37c69dfab3f0c41812348.tar.gz
gdb-277474eea03e0f77a9d37c69dfab3f0c41812348.tar.bz2
gdb: make inferior::terminal a unique ptr
This changes the inferior::terminal field to be a unique pointer, so its deallocation is automatically managed. gdb/ChangeLog: * inferior.h (struct inferior) <terminal>: Change type to gdb::unique_xmalloc_ptr<char>. * inferior.c (inferior::~inferior): Don't free inf->terminal. * infcmd.c (set_inferior_io_terminal): Don't free terminal field, adjust to unique pointer. (get_inferior_io_terminal): Adjust to unique pointer. Change-Id: Iedb6459b4f9eeae812b0cb9d514b5707d5107cdb
Diffstat (limited to 'gdb/infcmd.c')
-rw-r--r--gdb/infcmd.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index 42b050d..48d6a91 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -108,10 +108,8 @@ int stopped_by_random_signal;
void
set_inferior_io_terminal (const char *terminal_name)
{
- xfree (current_inferior ()->terminal);
-
if (terminal_name != NULL && *terminal_name != '\0')
- current_inferior ()->terminal = xstrdup (terminal_name);
+ current_inferior ()->terminal.reset (xstrdup (terminal_name));
else
current_inferior ()->terminal = NULL;
}
@@ -119,7 +117,7 @@ set_inferior_io_terminal (const char *terminal_name)
const char *
get_inferior_io_terminal (void)
{
- return current_inferior ()->terminal;
+ return current_inferior ()->terminal.get ();
}
static void