summaryrefslogtreecommitdiff
path: root/gdb/ui-file.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/ui-file.c')
-rw-r--r--gdb/ui-file.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/gdb/ui-file.c b/gdb/ui-file.c
index e6aaf93439a..1760b4c0528 100644
--- a/gdb/ui-file.c
+++ b/gdb/ui-file.c
@@ -22,6 +22,7 @@
#include "defs.h"
#include "ui-file.h"
+#include "gdb_obstack.h"
#include "gdb_string.h"
#include "gdb_select.h"
@@ -264,7 +265,7 @@ set_ui_file_data (struct ui_file *file, void *data,
}
/* ui_file utility function for converting a ``struct ui_file'' into
- a memory buffer''. */
+ a memory buffer. */
struct accumulated_ui_file
{
@@ -298,6 +299,23 @@ ui_file_xstrdup (struct ui_file *file, long *length)
*length = acc.length;
return acc.buffer;
}
+
+static void
+do_ui_file_obsavestring (void *context, const char *buffer, long length)
+{
+ struct obstack *obstack = (struct obstack *) context;
+ obstack_grow (obstack, buffer, length);
+}
+
+char *
+ui_file_obsavestring (struct ui_file *file, struct obstack *obstack,
+ long *length)
+{
+ ui_file_put (file, do_ui_file_obsavestring, obstack);
+ *length = obstack_object_size (obstack);
+ obstack_1grow (obstack, '\0');
+ return obstack_finish (obstack);
+}
/* A pure memory based ``struct ui_file'' that can be used an output
buffer. The buffers accumulated contents are available via