Fix minor memory leaks
This commit is contained in:
parent
b880e97990
commit
e89b0696d7
|
@ -50,7 +50,9 @@ LINE* mathopln(char op) {
|
|||
|
||||
LINE* pushconstant(int n) {
|
||||
char* tokens[] = { "push", "constant", itoa(n) };
|
||||
return mkln(tokens);
|
||||
LINE* ln = mkln(tokens);
|
||||
free(tokens[2]);
|
||||
return ln;
|
||||
}
|
||||
|
||||
LINE* pushthat() {
|
||||
|
|
|
@ -92,8 +92,12 @@ LINEBLOCK* compileif(COMPILER* c, SCOPE* s, IFSTATEMENT* st) {
|
|||
blk = mergelnblks(blk, compilestatements(c, s, st->elsestatements));
|
||||
char* endlabelln[] = { "label", endlabel };
|
||||
appendln(blk, mkln(endlabelln));
|
||||
free(endlabel);
|
||||
}
|
||||
|
||||
free(falselabel);
|
||||
free(truelabel);
|
||||
|
||||
return blk;
|
||||
}
|
||||
|
||||
|
@ -124,6 +128,9 @@ LINEBLOCK* compilewhile(COMPILER* c, SCOPE* s, CONDSTATEMENT* w) {
|
|||
char* endlabelln[] = { "label", endlabel };
|
||||
appendln(blk, mkln(endlabelln));
|
||||
|
||||
free(explabel);
|
||||
free(endlabel);
|
||||
|
||||
return blk;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
#include <stdlib.h>
|
||||
#include "compiler-util.h"
|
||||
|
||||
LINE* opvarraw(SCOPE* s, char* op, VAR* v) {
|
||||
char* tokens[] = { op, v->memsegment, itoa(v->index) };
|
||||
return mksimpleln(tokens, strcount(tokens));
|
||||
LINE* ln = mksimpleln(tokens, strcount(tokens));
|
||||
free(tokens[2]);
|
||||
return ln;
|
||||
}
|
||||
|
||||
LINE* opvar(SCOPE* s, char* op, const char* name) {
|
||||
|
|
Loading…
Reference in New Issue