public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] Remove struct buffer from tracefile-tfile.c
@ 2023-02-24 19:04 Tom Tromey
  0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2023-02-24 19:04 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=588d3013543f8aa0105838edde410a1936b6765c

commit 588d3013543f8aa0105838edde410a1936b6765c
Author: Tom Tromey <tom@tromey.com>
Date:   Fri Dec 16 07:42:47 2022 -0700

    Remove struct buffer from tracefile-tfile.c
    
    This changes tracefile-tfile.c to use std::string rather than struct
    buffer.

Diff:
---
 gdb/tracefile-tfile.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/gdb/tracefile-tfile.c b/gdb/tracefile-tfile.c
index 885fefd2df5..31eb974d416 100644
--- a/gdb/tracefile-tfile.c
+++ b/gdb/tracefile-tfile.c
@@ -31,7 +31,6 @@
 #include "remote.h"
 #include "xml-tdesc.h"
 #include "target-descriptions.h"
-#include "gdbsupport/buffer.h"
 #include "gdbsupport/pathstuff.h"
 #include <algorithm>
 
@@ -425,7 +424,7 @@ static off_t trace_frames_offset;
 static off_t cur_offset;
 static int cur_data_size;
 int trace_regblock_size;
-static struct buffer trace_tdesc;
+static std::string trace_tdesc;
 
 static void tfile_append_tdesc_line (const char *line);
 static void tfile_interp_line (char *line,
@@ -487,7 +486,7 @@ tfile_target_open (const char *arg, int from_tty)
   trace_fd = scratch_chan;
 
   /* Make sure this is clear.  */
-  buffer_free (&trace_tdesc);
+  trace_tdesc.clear ();
 
   bytes = 0;
   /* Read the file header and test for validity.  */
@@ -626,7 +625,7 @@ tfile_target::close ()
   trace_fd = -1;
   xfree (trace_filename);
   trace_filename = NULL;
-  buffer_free (&trace_tdesc);
+  trace_tdesc.clear ();
 
   trace_reset_local_state ();
 }
@@ -922,16 +921,16 @@ tfile_xfer_partial_features (const char *annex,
   if (readbuf == NULL)
     error (_("tfile_xfer_partial: tdesc is read-only"));
 
-  if (trace_tdesc.used_size == 0)
+  if (trace_tdesc.empty ())
     return TARGET_XFER_E_IO;
 
-  if (offset >= trace_tdesc.used_size)
+  if (offset >= trace_tdesc.length ())
     return TARGET_XFER_EOF;
 
-  if (len > trace_tdesc.used_size - offset)
-    len = trace_tdesc.used_size - offset;
+  if (len > trace_tdesc.length () - offset)
+    len = trace_tdesc.length () - offset;
 
-  memcpy (readbuf, trace_tdesc.buffer + offset, len);
+  memcpy (readbuf, trace_tdesc.c_str () + offset, len);
   *xfered_len = len;
 
   return TARGET_XFER_OK;
@@ -1128,8 +1127,8 @@ tfile_target::traceframe_info ()
 static void
 tfile_append_tdesc_line (const char *line)
 {
-  buffer_grow_str (&trace_tdesc, line);
-  buffer_grow_str (&trace_tdesc, "\n");
+  trace_tdesc += line;
+  trace_tdesc += "\n";
 }
 
 void _initialize_tracefile_tfile ();

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-02-24 19:04 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-24 19:04 [binutils-gdb] Remove struct buffer from tracefile-tfile.c Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).