This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[RFA 03/10] Use unique_xmalloc_ptr in env_execute_cli_command
- From: Tom Tromey <tom at tromey dot com>
- To: gdb-patches at sourceware dot org
- Cc: Tom Tromey <tom at tromey dot com>
- Date: Tue, 29 Aug 2017 13:25:17 -0600
- Subject: [RFA 03/10] Use unique_xmalloc_ptr in env_execute_cli_command
- Authentication-results: sourceware.org; auth=none
- References: <20170829192524.29971-1-tom@tromey.com>
Change env_execute_cli_command to use unique_xmalloc_ptr, removing a
cleanup.
ChangeLog
2017-08-29 Tom Tromey <tom@tromey.com>
* mi/mi-cmd-env.c (env_execute_cli_command): Use
gdb::unique_xmalloc_ptr.
---
gdb/ChangeLog | 5 +++++
gdb/mi/mi-cmd-env.c | 12 ++++--------
2 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 1c4896c..9c8bb47 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
2017-08-29 Tom Tromey <tom@tromey.com>
+ * mi/mi-cmd-env.c (env_execute_cli_command): Use
+ gdb::unique_xmalloc_ptr.
+
+2017-08-29 Tom Tromey <tom@tromey.com>
+
* thread.c (print_thread_info_1): Use string_printf.
(thread_apply_command, thread_apply_all_command): Use
std::string.
diff --git a/gdb/mi/mi-cmd-env.c b/gdb/mi/mi-cmd-env.c
index bf4578c..f24f387 100644
--- a/gdb/mi/mi-cmd-env.c
+++ b/gdb/mi/mi-cmd-env.c
@@ -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 */ );
}
}
--
2.9.4