diff options
author | Tom Tromey <tom@tromey.com> | 2018-04-16 21:09:48 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2018-05-04 15:58:05 -0600 |
commit | e2fc72e2c594968084b936bc5dc4702a2c0694f8 (patch) | |
tree | 70307653efb3b532fa403d7d8d783e2d7ed0e67e /gdb/cli/cli-decode.c | |
parent | a3b60e4588606354b93508a0008a5ca04b68fad8 (diff) | |
download | gdb-e2fc72e2c594968084b936bc5dc4702a2c0694f8.zip gdb-e2fc72e2c594968084b936bc5dc4702a2c0694f8.tar.gz gdb-e2fc72e2c594968084b936bc5dc4702a2c0694f8.tar.bz2 |
Allocate cmd_list_element with new
This adds a constructor and destructor to cmd_list_element and changes
it to be allocated with new. This will be useful in a subsequent
patch.
ChangeLog
2018-05-04 Tom Tromey <tom@tromey.com>
* cli/cli-decode.h (cmd_list_element): New constructor.
(~cmd_list_element): New destructor.
(struct cmd_list_element): Add initializers.
* cli/cli-decode.c (do_add_cmd): Use "new".
(delete_cmd): Use "delete".
Diffstat (limited to 'gdb/cli/cli-decode.c')
-rw-r--r-- | gdb/cli/cli-decode.c | 35 |
1 files changed, 3 insertions, 32 deletions
diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c index 0afe36a..c8dda70 100644 --- a/gdb/cli/cli-decode.c +++ b/gdb/cli/cli-decode.c @@ -193,7 +193,8 @@ static struct cmd_list_element * do_add_cmd (const char *name, enum command_class theclass, const char *doc, struct cmd_list_element **list) { - struct cmd_list_element *c = XNEW (struct cmd_list_element); + struct cmd_list_element *c = new struct cmd_list_element (name, theclass, + doc); struct cmd_list_element *p, *iter; /* Turn each alias of the old command into an alias of the new @@ -227,34 +228,6 @@ do_add_cmd (const char *name, enum command_class theclass, p->next = c; } - c->name = name; - c->theclass = theclass; - set_cmd_context (c, NULL); - c->doc = doc; - c->cmd_deprecated = 0; - c->deprecated_warn_user = 0; - c->malloced_replacement = 0; - c->doc_allocated = 0; - c->replacement = NULL; - c->pre_show_hook = NULL; - c->hook_in = 0; - c->prefixlist = NULL; - c->prefixname = NULL; - c->allow_unknown = 0; - c->prefix = NULL; - c->abbrev_flag = 0; - set_cmd_completer (c, symbol_completer); - c->completer_handle_brkchars = NULL; - c->destroyer = NULL; - c->type = not_set_cmd; - c->var = NULL; - c->var_type = var_boolean; - c->enums = NULL; - c->user_commands = NULL; - c->cmd_pointer = NULL; - c->alias_chain = NULL; - c->suppress_notification = NULL; - return c; } @@ -841,8 +814,6 @@ delete_cmd (const char *name, struct cmd_list_element **list, *prehookee = iter->hookee_pre; if (iter->hookee_post) iter->hookee_post->hook_post = 0; - if (iter->doc && iter->doc_allocated) - xfree ((char *) iter->doc); *posthook = iter->hook_post; *posthookee = iter->hookee_post; @@ -866,7 +837,7 @@ delete_cmd (const char *name, struct cmd_list_element **list, *prevp = iter->alias_chain; } - xfree (iter); + delete iter; /* We won't see another command with the same name. */ break; |