{
struct tfile_trace_file_writer *writer
= (struct tfile_trace_file_writer *) self;
- char *tdesc = target_fetch_description_xml (¤t_target);
- char *ptr = tdesc;
- char *next;
- if (tdesc == NULL)
+ gdb::optional<std::string> tdesc
+ = target_fetch_description_xml (¤t_target);
+
+ if (!tdesc)
return;
+ const char *ptr = tdesc->c_str ();
+
/* Write tdesc line by line, prefixing each line with "tdesc ". */
while (ptr != NULL)
{
- next = strchr (ptr, '\n');
+ const char *next = strchr (ptr, '\n');
if (next != NULL)
{
fprintf (writer->fp, "tdesc %.*s\n", (int) (next - ptr), ptr);
}
ptr = next;
}
-
- xfree (tdesc);
}
/* This is the implementation of trace_file_write_ops method