Use ui_file_as_string in gdb/ui-out.c
authorPedro Alves <palves@redhat.com>
Tue, 8 Nov 2016 15:26:44 +0000 (15:26 +0000)
committerPedro Alves <palves@redhat.com>
Tue, 8 Nov 2016 15:26:44 +0000 (15:26 +0000)
gdb/ChangeLog:
2016-11-08  Pedro Alves  <palves@redhat.com>

* ui-out.c (ui_out_field_stream): Use ui_file_as_string.

gdb/ChangeLog
gdb/ui-out.c

index 27605804907fbb1cbb76f34920f013c8576669b4..78557768238173acdf0c79839cd2fbd7999667e8 100644 (file)
@@ -1,3 +1,7 @@
+2016-11-08  Pedro Alves  <palves@redhat.com>
+
+       * ui-out.c (ui_out_field_stream): Use ui_file_as_string.
+
 2016-11-08  Pedro Alves  <palves@redhat.com>
 
        * ada-valprint.c (ada_print_floating): Use ui_file_as_string and
index 0eaa48fc9d00fc07dffdf7db8853a03509b63e11..60d18eee2bb0829213c84d836459edff41dc0ff3 100644 (file)
@@ -425,16 +425,13 @@ ui_out_field_stream (struct ui_out *uiout,
                     const char *fldname,
                     struct ui_file *stream)
 {
-  long length;
-  char *buffer = ui_file_xstrdup (stream, &length);
-  struct cleanup *old_cleanup = make_cleanup (xfree, buffer);
+  std::string buffer = ui_file_as_string (stream);
 
-  if (length > 0)
-    ui_out_field_string (uiout, fldname, buffer);
+  if (!buffer.empty ())
+    ui_out_field_string (uiout, fldname, buffer.c_str ());
   else
     ui_out_field_skip (uiout, fldname);
   ui_file_rewind (stream);
-  do_cleanups (old_cleanup);
 }
 
 /* Used to omit a field.  */