forked from Imagelibrary/binutils-gdb
New function null_stream
This patch adds a new function null_stream, which returns a null stream. The null stream can be used in multiple places. It is used in gdb_insn_length, and the following patches will use it too. gdb: 2017-01-26 Yao Qi <yao.qi@linaro.org> * disasm.c (do_ui_file_delete): Delete. (gdb_insn_length): Move code creating stream to ... * utils.c (null_stream): ... here. New function. * utils.h (null_stream): Declare.
This commit is contained in:
15
gdb/utils.c
15
gdb/utils.c
@@ -199,6 +199,21 @@ make_cleanup_ui_file_delete (struct ui_file *arg)
|
||||
return make_cleanup (do_ui_file_delete, arg);
|
||||
}
|
||||
|
||||
struct ui_file *
|
||||
null_stream (void)
|
||||
{
|
||||
/* A simple implementation of singleton pattern. */
|
||||
static struct ui_file *stream = NULL;
|
||||
|
||||
if (stream == NULL)
|
||||
{
|
||||
stream = ui_file_new ();
|
||||
/* Delete it on gdb exit. */
|
||||
make_final_cleanup (do_ui_file_delete, stream);
|
||||
}
|
||||
return stream;
|
||||
}
|
||||
|
||||
/* Helper function for make_cleanup_ui_out_redirect_pop. */
|
||||
|
||||
static void
|
||||
|
||||
Reference in New Issue
Block a user