+2020-06-25 Simon Marchi <simon.marchi@efficios.com>
+
+ * 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.
+
2020-06-25 Andrew Burgess <andrew.burgess@embecosm.com>
* riscv-tdep.c (riscv_print_registers_info): Loop over all
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;
}
const char *
get_inferior_io_terminal (void)
{
- return current_inferior ()->terminal;
+ return current_inferior ()->terminal.get ();
}
static void
discard_all_inferior_continuations (inf);
inferior_free_data (inf);
xfree (inf->args);
- xfree (inf->terminal);
target_desc_info_free (inf->tdesc_info);
}
#include "symfile-add-flags.h"
#include "gdbsupport/refcounted-object.h"
#include "gdbsupport/forward-scope-exit.h"
+#include "gdbsupport/gdb_unique_ptr.h"
#include "gdbsupport/common-inferior.h"
#include "gdbthread.h"
gdb::unique_xmalloc_ptr<char> cwd;
/* The name of terminal device to use for I/O. */
- char *terminal = NULL;
+ gdb::unique_xmalloc_ptr<char> terminal;
/* The terminal state as set by the last target_terminal::terminal_*
call. */