This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA 2/5] Introduce ui_file_up and use it to remove cleanups
- From: Trevor Saunders <tbsaunde at tbsaunde dot org>
- To: Tom Tromey <tom at tromey dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Mon, 16 Jan 2017 05:10:06 -0500
- Subject: Re: [RFA 2/5] Introduce ui_file_up and use it to remove cleanups
- Authentication-results: sourceware.org; auth=none
- References: <20170115134253.24018-1-tom@tromey.com> <20170115134253.24018-3-tom@tromey.com>
> +++ b/gdb/ada-lang.c
> @@ -7602,16 +7602,11 @@ ada_value_struct_elt (struct value *arg, char *name, int no_err)
> static std::string
> type_as_string (struct type *type)
> {
> - struct ui_file *tmp_stream = mem_fileopen ();
> - struct cleanup *old_chain;
> -
> - tmp_stream = mem_fileopen ();
> - old_chain = make_cleanup_ui_file_delete (tmp_stream);
> + ui_file_up tmp_stream = mem_fileopen ();
>
> - type_print (type, "", tmp_stream, -1);
> - std::string str = ui_file_as_string (tmp_stream);
> + type_print (type, "", tmp_stream.get (), -1);
> + std::string str = ui_file_as_string (tmp_stream.get ());
>
> - do_cleanups (old_chain);
> return str;
you could just get rid of the str variable here and a bunch of other
places right? Though obviously that can happen later.
Trev