diff options
author | Tom Tromey <tom@tromey.com> | 2022-06-22 17:31:17 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2023-07-10 13:02:11 -0600 |
commit | fb4e5d7dda1bd2dc37fa977d34225fd02b419e11 (patch) | |
tree | cb9241a92306f4b4c91b551b349af400b3448648 | |
parent | dd2532ad8af1676450114e4884ad748d528eafbe (diff) | |
download | gdb-fb4e5d7dda1bd2dc37fa977d34225fd02b419e11.zip gdb-fb4e5d7dda1bd2dc37fa977d34225fd02b419e11.tar.gz gdb-fb4e5d7dda1bd2dc37fa977d34225fd02b419e11.tar.bz2 |
Remove a use of xfree
This removes a use of xfree from tracefile-tfile.c, replacing it with
a unique_xmalloc_ptr.
Reviewed-by: Keith Seitz <keiths@redhat.com>
-rw-r--r-- | gdb/tracefile-tfile.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/gdb/tracefile-tfile.c b/gdb/tracefile-tfile.c index 9203bcc..ff451c7 100644 --- a/gdb/tracefile-tfile.c +++ b/gdb/tracefile-tfile.c @@ -225,22 +225,19 @@ static void tfile_write_uploaded_tsv (struct trace_file_writer *self, struct uploaded_tsv *utsv) { - char *buf = NULL; + gdb::unique_xmalloc_ptr<char> buf; struct tfile_trace_file_writer *writer = (struct tfile_trace_file_writer *) self; if (utsv->name) { - buf = (char *) xmalloc (strlen (utsv->name) * 2 + 1); - bin2hex ((gdb_byte *) (utsv->name), buf, strlen (utsv->name)); + buf.reset ((char *) xmalloc (strlen (utsv->name) * 2 + 1)); + bin2hex ((gdb_byte *) (utsv->name), buf.get (), strlen (utsv->name)); } fprintf (writer->fp, "tsv %x:%s:%x:%s\n", utsv->number, phex_nz (utsv->initial_value, 8), - utsv->builtin, buf != NULL ? buf : ""); - - if (utsv->name) - xfree (buf); + utsv->builtin, buf != NULL ? buf.get () : ""); } #define MAX_TRACE_UPLOAD 2000 |