Use std::string in do_set_command
authorTom Tromey <tom@tromey.com>
Sun, 13 Aug 2017 20:45:17 +0000 (14:45 -0600)
committerTom Tromey <tom@tromey.com>
Sun, 3 Sep 2017 19:03:07 +0000 (13:03 -0600)
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.

gdb/ChangeLog
gdb/cli/cli-setshow.c

index 6d6dad15ff57014bc0567a909be729d33f8c6e16..ba1397f9fdf87c1199da2b1571bf1c64066a23d6 100644 (file)
@@ -1,3 +1,7 @@
+2017-09-03  Tom Tromey  <tom@tromey.com>
+
+       * cli/cli-setshow.c (do_set_command): Use std::string.
+
 2017-09-03  Tom Tromey  <tom@tromey.com>
 
        * cli/cli-cmds.c (cd_command): Use gdb::unique_xmalloc_ptr.
index fb0bd490f50ae9d8855b780d7467f3925089c579..c6e5ebc49b988798434aa1cec3408fb63a7a9d9d 100644 (file)
@@ -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, ' ');
This page took 0.032367 seconds and 4 git commands to generate.