diff options
Diffstat (limited to 'src/lexer.c')
| -rw-r--r-- | src/lexer.c | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/src/lexer.c b/src/lexer.c index 829942a..47f76f0 100644 --- a/src/lexer.c +++ b/src/lexer.c @@ -128,6 +128,7 @@ lexer_handle_contentfor(directive_t *directive, size_t n) { directive->type = CONTENTFOR; + directive->operands = NULL; contentfor_operand_t *operands = malloc(sizeof(contentfor_operand_t)); for (size_t i = n + strlen("contentfor"); i < match->length; i++) @@ -163,8 +164,8 @@ lexer_handle_contentfor(directive_t *directive, } if (new_directive->type == ENDCONTENT) { - break; free(new_directive); + break; } free(new_directive); @@ -334,3 +335,30 @@ find_contentfor_value(list_t *content_headers, char *key) return NULL; } + +void +directive_delete(directive_t *directive) +{ + switch (directive->type) { + case EACHDO: { + eachdo_operands_t *operands = directive->operands; + free(operands->content); + free(operands->key); + free(operands); + } + case CONTENTFOR: { + contentfor_operand_t *operands = directive->operands; + free(operands->content); + free(operands->key); + free(operands); + } + case PUT: + case CONTENT: + case INCLUDE: + if (directive->operands != NULL) + free(directive->operands); + break; + default: + break; + } +} |
