diff options
author | Tom Tromey <tom@tromey.com> | 2017-08-13 14:45:17 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2017-09-03 13:03:07 -0600 |
commit | b57af50345945f32e6615391ac62a4f589c0fada (patch) | |
tree | 8326cc170c8fed11305ca91a2089f13fbac7e12f /gdb/cli | |
parent | 6eecf35f97e1d37e49e385ba599797dd1c8afd1f (diff) | |
download | gdb-b57af50345945f32e6615391ac62a4f589c0fada.zip gdb-b57af50345945f32e6615391ac62a4f589c0fada.tar.gz gdb-b57af50345945f32e6615391ac62a4f589c0fada.tar.bz2 |
Use std::string in do_set_command
Change do_set_command to use std::string, removing a cleanup and some
manual resizing code.
ChangeLog
2017-09-03 Tom Tromey <tom@tromey.com>
* cli/cli-setshow.c (do_set_command): Use std::string.
Diffstat (limited to 'gdb/cli')
-rw-r--r-- | gdb/cli/cli-setshow.c | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/gdb/cli/cli-setshow.c b/gdb/cli/cli-setshow.c index fb0bd49..c6e5ebc 100644 --- a/gdb/cli/cli-setshow.c +++ b/gdb/cli/cli-setshow.c @@ -367,24 +367,16 @@ do_set_command (const char *arg, int from_tty, struct cmd_list_element *c) message. */ if (arg == NULL) { - char *msg; - int msg_len = 0; - - for (i = 0; c->enums[i]; i++) - msg_len += strlen (c->enums[i]) + 2; - - msg = (char *) xmalloc (msg_len); - *msg = '\0'; - make_cleanup (xfree, msg); + std::string msg; for (i = 0; c->enums[i]; i++) { if (i != 0) - strcat (msg, ", "); - strcat (msg, c->enums[i]); + msg += ", "; + msg += c->enums[i]; } error (_("Requires an argument. Valid arguments are %s."), - msg); + msg.c_str ()); } p = strchr (arg, ' '); |