diff --git a/assembler.c b/assembler.c index 7130315..182f4ae 100644 --- a/assembler.c +++ b/assembler.c @@ -238,6 +238,7 @@ void striplabels(ASSEMBLER* a) { a->lns = curln->next; LINELIST* tmp = curln; curln = curln->next; + free(tmp->content); free(tmp); } else { @@ -372,8 +373,17 @@ void translate(ASSEMBLER* a) { } } +void freelns(LINELIST* lns) { + LINELIST* next = lns->next; + free(lns->content); + free(lns); + if(next != NULL) + freelns(next); +} + void freeassembler(ASSEMBLER* a) { freesymbols(a->vars); freesymbols(a->labels); + freelns(a->lns); free(a); } diff --git a/main.c b/main.c index 0e38d45..381bf42 100644 --- a/main.c +++ b/main.c @@ -35,6 +35,7 @@ int main(int argc, char* argv[]) { parse(p); ASSEMBLER* a = mkassembler(p->output); + free(p); // variable substitution preprocess(a); diff --git a/parser.h b/parser.h index d7d8a9a..3f5676d 100644 --- a/parser.h +++ b/parser.h @@ -15,4 +15,5 @@ typedef struct { PARSER* mkparser(FILE* input); void parse(PARSER* p); +void freeparser(PARSER* p); #endif