diff options
Diffstat (limited to 'src/fwdscript.c')
| -rw-r--r-- | src/fwdscript.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/fwdscript.c b/src/fwdscript.c index 1c9cff2..c197e2f 100644 --- a/src/fwdscript.c +++ b/src/fwdscript.c @@ -419,18 +419,31 @@ static int fwdscript_tokenize(struct fwdtokens *tokens, const char *buf) return 0; } +static void free_tokens(struct fwdtokens *tokens) +{ + foreach(fwdtokens, token, tokens) { + switch (token->kind) { + case FWDTOKEN_STR: + case FWDTOKEN_ID: free(token->s); + default: break; + } + } + + fwdtokens_destroy(tokens); +} + static int fwdscript_parse(struct fwdscript *s, const char *buf) { struct fwdtokens tokens = fwdtokens_create(0); if (fwdscript_tokenize(&tokens, buf)) { - fwdtokens_destroy(&tokens); + free_tokens(&tokens); return -1; } /* convert tokens into some kind of structure */ TODO(); - fwdtokens_destroy(&tokens); + free_tokens(&tokens); return 0; } |
