aboutsummaryrefslogtreecommitdiff
path: root/gdb/tui
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2017-10-09 19:13:31 -0600
committerTom Tromey <tom@tromey.com>2017-10-11 16:21:43 -0600
commitf71c8822611a552e76843142a52b8197be0ea34a (patch)
treeae626428b83e68b04492225f589ba1e65d6e9a44 /gdb/tui
parent981a3fb3594dddae266b7a5014c3001727200d7b (diff)
downloadgdb-f71c8822611a552e76843142a52b8197be0ea34a.zip
gdb-f71c8822611a552e76843142a52b8197be0ea34a.tar.gz
gdb-f71c8822611a552e76843142a52b8197be0ea34a.tar.bz2
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 <tom@tromey.com> * tui/tui-win.c (tui_set_win_height, parse_scrolling_args): Use std::string. * tui/tui-layout.c (enum tui_status): Use std::string.
Diffstat (limited to 'gdb/tui')
-rw-r--r--gdb/tui/tui-layout.c11
-rw-r--r--gdb/tui/tui-win.c15
2 files changed, 9 insertions, 17 deletions
diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index eab1ab6..fe68331 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 7dbd76b..26b6b5e 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 = &copy[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 = &copy[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);
}
}