diff options
author | Tom Tromey <tom@tromey.com> | 2017-09-29 22:07:37 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2017-10-03 05:33:45 -0600 |
commit | b95de2b7aeb30081345954cb15970a582b49a866 (patch) | |
tree | b562ca7cca16ad171cf074074b89e11311970216 /gdb/utils.c | |
parent | 070365117b5727394e271399c5738a27bf9716d5 (diff) | |
download | gdb-b95de2b7aeb30081345954cb15970a582b49a866.zip gdb-b95de2b7aeb30081345954cb15970a582b49a866.tar.gz gdb-b95de2b7aeb30081345954cb15970a582b49a866.tar.bz2 |
Remove set_batch_flag_and_make_cleanup_restore_page_info
This removes set_batch_flag_and_make_cleanup_restore_page_info and
make_cleanup_restore_page_info in favor of a new RAII class. This
then allows for the removal of make_cleanup_restore_uinteger and
make_cleanup_restore_integer
ChangeLog
2017-10-03 Tom Tromey <tom@tromey.com>
* guile/scm-ports.c (ioscm_with_output_to_port_worker): Update.
* top.c (execute_command_to_string): Update.
* utils.c (make_cleanup_restore_page_info): Remove.
(do_restore_page_info_cleanup): Remove.
(set_batch_flag_and_restore_page_info):
New.
(make_cleanup_restore_page_info): Remove.
(set_batch_flag_and_make_cleanup_restore_page_info): Remove.
(~set_batch_flag_and_restore_page_info): New
(make_cleanup_restore_uinteger): Remove.
(make_cleanup_restore_integer): Remove.
(struct restore_integer_closure): Remove.
(restore_integer): Remove.
* utils.h (struct set_batch_flag_and_restore_page_info): New
class.
(set_batch_flag_and_make_cleanup_restore_page_info): Remove.
(make_cleanup_restore_page_info): Remove.
(make_cleanup_restore_uinteger) Remove.
(make_cleanup_restore_integer) Remove.
Diffstat (limited to 'gdb/utils.c')
-rw-r--r-- | gdb/utils.c | 81 |
1 files changed, 12 insertions, 69 deletions
diff --git a/gdb/utils.c b/gdb/utils.c index b2e0813..0c59b4e 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -150,44 +150,6 @@ make_cleanup_free_section_addr_info (struct section_addr_info *addrs) return make_cleanup (do_free_section_addr_info, addrs); } -struct restore_integer_closure -{ - int *variable; - int value; -}; - -static void -restore_integer (void *p) -{ - struct restore_integer_closure *closure - = (struct restore_integer_closure *) p; - - *(closure->variable) = closure->value; -} - -/* Remember the current value of *VARIABLE and make it restored when - the cleanup is run. */ - -struct cleanup * -make_cleanup_restore_integer (int *variable) -{ - struct restore_integer_closure *c = XNEW (struct restore_integer_closure); - - c->variable = variable; - c->value = *variable; - - return make_cleanup_dtor (restore_integer, (void *) c, xfree); -} - -/* Remember the current value of *VARIABLE and make it restored when - the cleanup is run. */ - -struct cleanup * -make_cleanup_restore_uinteger (unsigned int *variable) -{ - return make_cleanup_restore_integer ((int *) variable); -} - /* Helper for make_cleanup_unpush_target. */ static void @@ -1464,42 +1426,23 @@ filtered_printing_initialized (void) return wrap_buffer != NULL; } -/* Helper for make_cleanup_restore_page_info. */ - -static void -do_restore_page_info_cleanup (void *arg) -{ - set_screen_size (); - set_width (); -} - -/* Provide cleanup for restoring the terminal size. */ - -struct cleanup * -make_cleanup_restore_page_info (void) +set_batch_flag_and_restore_page_info::set_batch_flag_and_restore_page_info () + : m_save_lines_per_page (lines_per_page), + m_save_chars_per_line (chars_per_line), + m_save_batch_flag (batch_flag) { - struct cleanup *back_to; - - back_to = make_cleanup (do_restore_page_info_cleanup, NULL); - make_cleanup_restore_uinteger (&lines_per_page); - make_cleanup_restore_uinteger (&chars_per_line); - - return back_to; + batch_flag = 1; + init_page_info (); } -/* Temporarily set BATCH_FLAG and the associated unlimited terminal size. - Provide cleanup for restoring the original state. */ - -struct cleanup * -set_batch_flag_and_make_cleanup_restore_page_info (void) +set_batch_flag_and_restore_page_info::~set_batch_flag_and_restore_page_info () { - struct cleanup *back_to = make_cleanup_restore_page_info (); - - make_cleanup_restore_integer (&batch_flag); - batch_flag = 1; - init_page_info (); + batch_flag = m_save_batch_flag; + chars_per_line = m_save_chars_per_line; + lines_per_page = m_save_lines_per_page; - return back_to; + set_screen_size (); + set_width (); } /* Set the screen size based on LINES_PER_PAGE and CHARS_PER_LINE. */ |