aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2023-07-09 09:05:21 -0600
committerTom Tromey <tom@tromey.com>2023-07-10 13:02:11 -0600
commitd4ea64fb5dd7bb79026c3bfacd06495d5f8e6702 (patch)
treef3d4e5f786d23e7a2ebb6bde4c5f9fd734e82f12
parentc7b3e7462aba24ce65fd38e367bca976cfddaee2 (diff)
downloadgdb-d4ea64fb5dd7bb79026c3bfacd06495d5f8e6702.zip
gdb-d4ea64fb5dd7bb79026c3bfacd06495d5f8e6702.tar.gz
gdb-d4ea64fb5dd7bb79026c3bfacd06495d5f8e6702.tar.bz2
Use unique_ptr for trace_dirname
This changes trace_dirname to use unique_ptr, removing some manual memory management. Reviewed-by: Keith Seitz <keiths@redhat.com>
-rw-r--r--gdb/tracectf.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/gdb/tracectf.c b/gdb/tracectf.c
index 8f6ea25..fca623b 100644
--- a/gdb/tracectf.c
+++ b/gdb/tracectf.c
@@ -862,7 +862,7 @@ static struct bt_ctf_iter *ctf_iter = NULL;
static struct bt_iter_pos *start_pos;
/* The name of CTF directory. */
-static char *trace_dirname;
+static gdb::unique_xmalloc_ptr<char> trace_dirname;
static ctf_target ctf_ops;
@@ -1164,7 +1164,7 @@ ctf_target_open (const char *dirname, int from_tty)
start_pos = bt_iter_get_pos (bt_ctf_get_iter (ctf_iter));
gdb_assert (start_pos->type == BT_SEEK_RESTORE);
- trace_dirname = xstrdup (dirname);
+ trace_dirname = make_unique_xstrdup (dirname);
current_inferior ()->push_target (&ctf_ops);
inferior_appeared (current_inferior (), CTF_PID);
@@ -1185,8 +1185,7 @@ void
ctf_target::close ()
{
ctf_destroy ();
- xfree (trace_dirname);
- trace_dirname = NULL;
+ trace_dirname.reset ();
switch_to_no_thread (); /* Avoid confusion from thread stuff. */
exit_inferior_silent (current_inferior ());
@@ -1200,7 +1199,7 @@ ctf_target::close ()
void
ctf_target::files_info ()
{
- gdb_printf ("\t`%s'\n", trace_dirname);
+ gdb_printf ("\t`%s'\n", trace_dirname.get ());
}
/* This is the implementation of target_ops method to_fetch_registers.