diff options
author | Tom Tromey <tom@tromey.com> | 2017-04-07 15:34:02 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2017-04-12 11:16:18 -0600 |
commit | 4d89769a7b4e38e94a6e027281b36eff71fc8214 (patch) | |
tree | c99858aecfb6b30141f0c626556f8e89144038f9 /gdb/mi/mi-main.c | |
parent | 4b217cc72b7ab04e2bea519f9fbd47d8952e08f5 (diff) | |
download | gdb-4d89769a7b4e38e94a6e027281b36eff71fc8214.zip gdb-4d89769a7b4e38e94a6e027281b36eff71fc8214.tar.gz gdb-4d89769a7b4e38e94a6e027281b36eff71fc8214.tar.bz2 |
C++ify mi_parse
This changes mi_parse to return a unique_ptr, and to use "new"; then
fixes up the users. This allows removing one cleanup.
gdb/ChangeLog
2017-04-12 Tom Tromey <tom@tromey.com>
* mi/mi-parse.h (struct mi_parse): Add constructor, destructor.
(mi_parse): Update return type.
(mi_parse_free): Remove.
* mi/mi-parse.c (mi_parse::mi_parse): New constructor.
(mi_parse::~mi_parse): Rename from mi_parse_free.
(mi_parse_cleanup): Remove.
(mi_parse): Return a unique_ptr. Use new.
* mi/mi-main.c (mi_execute_command): Update.
Diffstat (limited to 'gdb/mi/mi-main.c')
-rw-r--r-- | gdb/mi/mi-main.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c index 91fe104..d99c40e 100644 --- a/gdb/mi/mi-main.c +++ b/gdb/mi/mi-main.c @@ -2117,7 +2117,7 @@ void mi_execute_command (const char *cmd, int from_tty) { char *token; - struct mi_parse *command = NULL; + std::unique_ptr<struct mi_parse> command; /* This is to handle EOF (^D). We just quit gdb. */ /* FIXME: we should call some API function here. */ @@ -2158,7 +2158,7 @@ mi_execute_command (const char *cmd, int from_tty) TRY { - captured_mi_execute_command (current_uiout, command); + captured_mi_execute_command (current_uiout, command.get ()); } CATCH (result, RETURN_MASK_ALL) { @@ -2186,7 +2186,7 @@ mi_execute_command (const char *cmd, int from_tty) && thread_count () != 0 /* If the command already reports the thread change, no need to do it again. */ - && !command_notifies_uscc_observer (command)) + && !command_notifies_uscc_observer (command.get ())) { struct mi_interp *mi = (struct mi_interp *) top_level_interpreter (); int report_change = 0; @@ -2211,8 +2211,6 @@ mi_execute_command (const char *cmd, int from_tty) } } - mi_parse_free (command); - do_cleanups (cleanup); } } |