From fb4e5d7dda1bd2dc37fa977d34225fd02b419e11 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Wed, 22 Jun 2022 17:31:17 -0600 Subject: [PATCH] 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 --- gdb/tracefile-tfile.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/gdb/tracefile-tfile.c b/gdb/tracefile-tfile.c index 9203bcc2e4b..ff451c79e88 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 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 -- 2.30.2