This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH v2 11/31] Use ui_file_as_string in gdb/ui-out.c
- From: Pedro Alves <palves at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Wed, 19 Oct 2016 02:11:59 +0100
- Subject: [PATCH v2 11/31] Use ui_file_as_string in gdb/ui-out.c
- Authentication-results: sourceware.org; auth=none
- References: <1476839539-8374-1-git-send-email-palves@redhat.com>
gdb/ChangeLog:
yyyy-mm-yy Pedro Alves <palves@redhat.com>
* ui-out.c (ui_out_field_stream): Use ui_file_as_string.
---
gdb/ui-out.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/gdb/ui-out.c b/gdb/ui-out.c
index f6d6050..9b1df3c 100644
--- a/gdb/ui-out.c
+++ b/gdb/ui-out.c
@@ -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. */
--
2.5.5