Fix memory leaks
This commit is contained in:
parent
e456ace07b
commit
c8dabe7abc
10
assembler.c
10
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);
|
||||
}
|
||||
|
|
1
main.c
1
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);
|
||||
|
|
Loading…
Reference in New Issue