Use unique_xmalloc_ptr in env_execute_cli_command
authorTom Tromey <tom@tromey.com>
Sun, 13 Aug 2017 16:57:05 +0000 (10:57 -0600)
committerTom Tromey <tom@tromey.com>
Sun, 3 Sep 2017 19:03:04 +0000 (13:03 -0600)
Change env_execute_cli_command to use unique_xmalloc_ptr, removing a
cleanup.

ChangeLog
2017-09-03  Tom Tromey  <tom@tromey.com>

* mi/mi-cmd-env.c (env_execute_cli_command): Use
gdb::unique_xmalloc_ptr.

gdb/ChangeLog
gdb/mi/mi-cmd-env.c

index 73847c56d8fbe5e6cfe7772cc0e527e1115064ac..72b52f582fd9eea21e67ce6d0523d0392be44b68 100644 (file)
@@ -1,3 +1,8 @@
+2017-09-03  Tom Tromey  <tom@tromey.com>
+
+       * mi/mi-cmd-env.c (env_execute_cli_command): Use
+       gdb::unique_xmalloc_ptr.
+
 2017-09-03  Tom Tromey  <tom@tromey.com>
 
        * thread.c (print_thread_info_1): Use string_printf.
index bf4578cd3322a3cf9cb2da404e4cc662affeca87..f24f387b14fcaff4d33747be60c9bab85bae867b 100644 (file)
@@ -48,17 +48,13 @@ env_execute_cli_command (const char *cmd, const char *args)
 {
   if (cmd != 0)
     {
-      struct cleanup *old_cleanups;
-      char *run;
+      gdb::unique_xmalloc_ptr<char> run;
 
       if (args != NULL)
-       run = xstrprintf ("%s %s", cmd, args);
+       run.reset (xstrprintf ("%s %s", cmd, args));
       else
-       run = xstrdup (cmd);
-      old_cleanups = make_cleanup (xfree, run);
-      execute_command ( /*ui */ run, 0 /*from_tty */ );
-      do_cleanups (old_cleanups);
-      return;
+       run.reset (xstrdup (cmd));
+      execute_command ( /*ui */ run.get (), 0 /*from_tty */ );
     }
 }
 
This page took 0.033599 seconds and 4 git commands to generate.