summaryrefslogtreecommitdiff
path: root/lib/command_match.c
diff options
context:
space:
mode:
authorQuentin Young <qlyoung@cumulusnetworks.com>2016-09-13 19:55:37 +0000
committerQuentin Young <qlyoung@cumulusnetworks.com>2016-09-13 19:55:37 +0000
commit795d02785aa3f6d1638d79cfdaa5e45ed2ff8199 (patch)
treee9eb9c4e32c9ca7b9bde3dfc0ac9de33afa55171 /lib/command_match.c
parent67c02c9449671a12bcaaaf71b06efd7989ebc026 (diff)
lib: Fix various memory leaks
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Diffstat (limited to 'lib/command_match.c')
-rw-r--r--lib/command_match.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/lib/command_match.c b/lib/command_match.c
index 75780de2c5..cd2200e0c0 100644
--- a/lib/command_match.c
+++ b/lib/command_match.c
@@ -101,14 +101,17 @@ command_match (struct graph *cmdgraph,
struct graph_node *start = vector_slot (cmdgraph->nodes, 0);
if ((*argv = command_match_r (start, vvline, 0))) // successful match
{
+ struct listnode *head = listhead (*argv);
+ struct listnode *tail = listtail (*argv);
+
// delete dummy start node
- list_delete_node (*argv, listhead (*argv));
+ del_cmd_token ((struct cmd_token_t *) head->data);
+ list_delete_node (*argv, head);
+
// get cmd_element out of list tail
- struct listnode *tail = listtail (*argv);
*el = listgetdata (tail);
- // delete list tail
- tail->data = NULL;
list_delete_node (*argv, tail);
+
// now argv is an ordered list of cmd_token matching the user
// input, with each cmd_token->arg holding the corresponding input
assert (*el);
@@ -290,7 +293,7 @@ command_complete (struct graph *graph,
unsigned int idx;
for (idx = 0; idx < vector_active (vline) && next->count > 0; idx++)
{
- list_free (current);
+ list_delete (current);
current = next;
next = list_new();
@@ -334,8 +337,8 @@ command_complete (struct graph *graph,
for (ALL_LIST_ELEMENTS_RO (next,node,gn))
listnode_add (*completions, gn->data);
- list_free (current);
- list_free (next);
+ list_delete (current);
+ list_delete (next);
return matcher_rv;
}