From b5a1e9ef5c7b1e505e6d82ea9c542748005afe63 Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Wed, 23 Nov 2016 12:06:34 +0100 Subject: [PATCH] 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 --- lib/command.c | 21 --------------------- lib/command.h | 6 ------ lib/command_parse.y | 2 +- 3 files changed, 1 insertion(+), 28 deletions(-) diff --git a/lib/command.c b/lib/command.c index 3ad0ca92d7..85053aaa8a 100644 --- a/lib/command.c +++ b/lib/command.c @@ -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 () { diff --git a/lib/command.h b/lib/command.h index c9b3440b02..ba6fd9b7b0 100644 --- a/lib/command.h +++ b/lib/command.h @@ -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 *); diff --git a/lib/command_parse.y b/lib/command_parse.y index d084ddd73f..a5e582c73b 100644 --- a/lib/command_parse.y +++ b/lib/command_parse.y @@ -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."); -- 2.39.5