lib: remove misleading copy/del_cmd_element

struct cmd_element items are static global variables, they are never
allocated, copied or freed.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
This commit is contained in:
David Lamparter 2016-11-23 12:06:34 +01:00
parent e9484f70b2
commit b5a1e9ef5c
3 changed files with 1 additions and 28 deletions

View File

@ -2445,27 +2445,6 @@ copy_cmd_token (struct cmd_token *token)
return copy;
}
void
del_cmd_element(struct cmd_element *cmd)
{
if (!cmd) return;
free ((char *) cmd->string);
free ((char *) cmd->doc);
free (cmd);
}
struct cmd_element *
copy_cmd_element(const struct cmd_element *cmd)
{
struct cmd_element *el = XMALLOC(MTYPE_CMD_TOKENS, sizeof (struct cmd_element));
el->string = cmd->string ? XSTRDUP(MTYPE_CMD_TOKENS, cmd->string) : NULL;
el->func = cmd->func;
el->doc = cmd->doc ? XSTRDUP(MTYPE_CMD_TOKENS, cmd->doc) : NULL;
el->daemon = cmd->daemon;
el->attr = cmd->attr;
return el;
}
void
cmd_terminate ()
{

View File

@ -417,12 +417,6 @@ extern void cmd_terminate (void);
extern void cmd_exit (struct vty *vty);
extern int cmd_list_cmds (struct vty *vty, int do_permute);
/* memory management for cmd_element */
void
del_cmd_element(struct cmd_element *);
struct cmd_element *
copy_cmd_element(const struct cmd_element *cmd);
/* memory management for cmd_token */
struct cmd_token *
new_cmd_token (enum cmd_token_type, u_char attr, char *, char *);

View File

@ -458,7 +458,7 @@ terminate_graph (struct parser_ctx *ctx, struct graph_node *finalnode)
strdup (CMD_CR_TEXT),
strdup (""));
struct graph_node *end_element_node =
graph_new_node (ctx->graph, element, (void (*)(void *)) &del_cmd_element);
graph_new_node (ctx->graph, element, NULL);
if (node_adjacent (finalnode, end_token_node))
cmd_yyerror (ctx, "Duplicate command.");