From: Tom Tromey Date: Tue, 10 Oct 2017 01:13:31 +0000 (-0600) Subject: Remove cleanups from TUI X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f71c8822611a552e76843142a52b8197be0ea34a;p=binutils-gdb.git Remove cleanups from TUI This removes the last cleanups from the TUI, by using std::string rather than manual memory management. Regression tested against gdb.tui/*.exp on Fedora 26 x86-64. gdb/ChangeLog 2017-10-09 Tom Tromey * tui/tui-win.c (tui_set_win_height, parse_scrolling_args): Use std::string. * tui/tui-layout.c (enum tui_status): Use std::string. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 60be796404a..532c2b99631 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2017-10-09 Tom Tromey + + * tui/tui-win.c (tui_set_win_height, parse_scrolling_args): Use + std::string. + * tui/tui-layout.c (enum tui_status): Use std::string. + 2017-10-11 Tom Tromey * gdbthread.h (thread_command): Constify. diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c index eab1ab6336d..fe68331b5b9 100644 --- a/gdb/tui/tui-layout.c +++ b/gdb/tui/tui-layout.c @@ -404,15 +404,13 @@ tui_set_layout_by_name (const char *layout_name) if (layout_name != (char *) NULL) { int i; - char *buf_ptr; enum tui_layout_type new_layout = UNDEFINED_LAYOUT; enum tui_layout_type cur_layout = tui_current_layout (); - struct cleanup *old_chain; - buf_ptr = (char *) xstrdup (layout_name); - for (i = 0; (i < strlen (layout_name)); i++) - buf_ptr[i] = toupper (buf_ptr[i]); - old_chain = make_cleanup (xfree, buf_ptr); + std::string copy = layout_name; + for (i = 0; i < copy.size (); i++) + copy[i] = toupper (copy[i]); + const char *buf_ptr = copy.c_str (); /* First check for ambiguous input. */ if (strlen (buf_ptr) <= 1 && *buf_ptr == 'S') @@ -450,7 +448,6 @@ tui_set_layout_by_name (const char *layout_name) tui_set_layout (new_layout); } } - do_cleanups (old_chain); } else status = TUI_FAILURE; diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c index 7dbd76b043f..26b6b5e8f5f 100644 --- a/gdb/tui/tui-win.c +++ b/gdb/tui/tui-win.c @@ -1165,14 +1165,13 @@ tui_set_win_height (char *arg, int from_tty) tui_enable (); if (arg != (char *) NULL) { - char *buf = xstrdup (arg); + std::string copy = arg; + char *buf = ©[0]; char *buf_ptr = buf; char *wname = NULL; int new_height, i; struct tui_win_info *win_info; - struct cleanup *old_chain; - old_chain = make_cleanup (xfree, buf); wname = buf_ptr; buf_ptr = strchr (buf_ptr, ' '); if (buf_ptr != (char *) NULL) @@ -1234,8 +1233,6 @@ The window name specified must be valid and visible.\n")); } else printf_filtered (WIN_HEIGHT_USAGE); - - do_cleanups (old_chain); } else printf_filtered (WIN_HEIGHT_USAGE); @@ -1661,12 +1658,11 @@ parse_scrolling_args (char *arg, window name arg. */ if (arg != (char *) NULL) { - char *buf, *buf_ptr; - struct cleanup *old_chain; + char *buf_ptr; /* Process the number of lines to scroll. */ - buf = buf_ptr = xstrdup (arg); - old_chain = make_cleanup (xfree, buf); + std::string copy = arg; + buf_ptr = ©[0]; if (isdigit (*buf_ptr)) { char *num_str; @@ -1713,6 +1709,5 @@ The window name specified must be valid and visible.\n")); else if (*win_to_scroll == TUI_CMD_WIN) *win_to_scroll = (tui_source_windows ())->list[0]; } - do_cleanups (old_chain); } }