fix(lexer): destroy_lexer_context now fully functional
This commit is contained in:
parent
5de6ef2bb5
commit
4289700e2e
1 changed files with 6 additions and 4 deletions
|
|
@ -259,12 +259,14 @@ struct token *new_token(char *begin, ssize_t size, struct token_info *info)
|
||||||
|
|
||||||
void destroy_lexer_context(struct lexer_context *ctx)
|
void destroy_lexer_context(struct lexer_context *ctx)
|
||||||
{
|
{
|
||||||
|
struct token *prev = ctx->previous_token;
|
||||||
|
struct token *cur = ctx->current_token;
|
||||||
if (ctx == NULL)
|
if (ctx == NULL)
|
||||||
return;
|
return;
|
||||||
if (ctx->previous_token != NULL)
|
if (prev != NULL)
|
||||||
free(ctx->previous_token);
|
free_token(&prev);
|
||||||
if (ctx->current_token != NULL)
|
if (cur != NULL)
|
||||||
free(ctx->current_token);
|
free_token(&cur);
|
||||||
free(ctx);
|
free(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue