diff options
| author | Quentin Young <qlyoung@cumulusnetworks.com> | 2016-09-13 19:55:37 +0000 |
|---|---|---|
| committer | Quentin Young <qlyoung@cumulusnetworks.com> | 2016-09-13 19:55:37 +0000 |
| commit | 795d02785aa3f6d1638d79cfdaa5e45ed2ff8199 (patch) | |
| tree | e9eb9c4e32c9ca7b9bde3dfc0ac9de33afa55171 /lib/grammar_sandbox.c | |
| parent | 67c02c9449671a12bcaaaf71b06efd7989ebc026 (diff) | |
lib: Fix various memory leaks
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Diffstat (limited to 'lib/grammar_sandbox.c')
| -rw-r--r-- | lib/grammar_sandbox.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/grammar_sandbox.c b/lib/grammar_sandbox.c index 1fe46a87e5..5e01e6c05b 100644 --- a/lib/grammar_sandbox.c +++ b/lib/grammar_sandbox.c @@ -84,7 +84,7 @@ DEFUN (grammar_test_complete, vector command = cmd_make_strvec (cmdstr); // generate completions of user input - struct list *completions = list_new (); + struct list *completions; enum matcher_rv result = command_complete (nodegraph, command, &completions); // print completions or relevant error message @@ -106,6 +106,10 @@ DEFUN (grammar_test_complete, tkn = vector_slot (comps, i); fprintf (stdout, " %-*s %s%s", width, tkn->text, tkn->desc, "\n"); } + + for (i = 0; i < vector_active (comps); i++) + del_cmd_token ((struct cmd_token_t *) vector_slot (comps, i)); + vector_free (comps); } else fprintf (stdout, "%% No match%s", "\n"); @@ -147,6 +151,7 @@ DEFUN (grammar_test_match, fprintf (stdout, "func: %p%s", element->func, "\n"); list_delete (argvv); + del_cmd_element (element); } else { assert(MATCHER_ERROR(result)); @@ -167,8 +172,8 @@ DEFUN (grammar_test_match, } // free resources - cmd_free_strvec(command); - free(cmdstr); + cmd_free_strvec (command); + free (cmdstr); return CMD_SUCCESS; } @@ -351,6 +356,7 @@ new_cmd_token (enum cmd_token_type_t type, char *text, char *desc) void del_cmd_token (struct cmd_token_t *token) { + fprintf (stdout, "deleting token\n"); if (!token) return; if (token->text) |
