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)
|
||||
{
|
||||
struct token *prev = ctx->previous_token;
|
||||
struct token *cur = ctx->current_token;
|
||||
if (ctx == NULL)
|
||||
return;
|
||||
if (ctx->previous_token != NULL)
|
||||
free(ctx->previous_token);
|
||||
if (ctx->current_token != NULL)
|
||||
free(ctx->current_token);
|
||||
if (prev != NULL)
|
||||
free_token(&prev);
|
||||
if (cur != NULL)
|
||||
free_token(&cur);
|
||||
free(ctx);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue