diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2026-08-01 00:02:00 +0300 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2026-08-01 00:02:00 +0300 |
| commit | 3b2611bb1b4004bb39df77050f1e31fbf73b084d (patch) | |
| tree | 2f4a8453c814784abb83822514ec316d945f4cf0 | |
| parent | 2c213605d612d6f84b8bd7738e36389c76543880 (diff) | |
| download | fwdscript-3b2611bb1b4004bb39df77050f1e31fbf73b084d.tar.gz fwdscript-3b2611bb1b4004bb39df77050f1e31fbf73b084d.zip | |
better token cleanup
| -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; } |
