scc

Simple C99 Compiler
Log | Files | Refs | README | LICENSE

commit f41175b80c5d599aba9fa70611adf5e94bf4c6e1
parent 68ccb5a199aa86efb8b07f550a64860cb5da950d
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Sun, 10 May 2015 18:16:12 +0200

Free trees after emit them

After they being used it doesn't make sense don't free the nodes

Diffstat:
cc1/code.c | 2++
cc1/stmt.c | 11-----------
2 files changed, 2 insertions(+), 11 deletions(-)

diff --git a/cc1/code.c b/cc1/code.c @@ -251,6 +251,7 @@ emitexp(uint8_t op, void *arg) emitnode(np); putchar('\n'); + freetree(np); } static void @@ -261,6 +262,7 @@ emitprint(uint8_t op, void *arg) emitnode(np); printf("\tk%c\n", np->type->letter); fflush(stdout); + freetree(np); } static void diff --git a/cc1/stmt.c b/cc1/stmt.c @@ -43,7 +43,6 @@ stmtexp(Symbol *lbreak, Symbol *lcont, Caselist *lswitch) } expect(';'); - freetree(np); } static Node * @@ -85,7 +84,6 @@ While(Symbol *lbreak, Symbol *lcont, Caselist *lswitch) emit(OEXPR, np); emit(OELOOP, NULL); emit(OLABEL, end); - freetree(np); } static void @@ -118,9 +116,6 @@ For(Symbol *lbreak, Symbol *lcont, Caselist *lswitch) emit(OEXPR, econd); emit(OELOOP, NULL); emit(OLABEL, end); - freetree(einit); - freetree(econd); - freetree(einc); } static void @@ -141,7 +136,6 @@ Dowhile(Symbol *lbreak, Symbol *lcont, Caselist *lswitch) emit(OEXPR, np); emit(OELOOP, NULL); emit(OLABEL, end); - freetree(np); } static void @@ -165,7 +159,6 @@ Return(Symbol *lbreak, Symbol *lcont, Caselist *lswitch) } emit(ORET, tp); emit(OEXPR, np); - freetree(np); } static void @@ -244,13 +237,11 @@ Switch(Symbol *lbreak, Symbol *lcont, Caselist *lswitch) emit(OCASE, p->label); emit(OEXPR, p->expr); next = p->next; - freetree(p->expr); free(p); } if (lcase.deflabel) emit(ODEFAULT, lcase.deflabel); emit(OLABEL, lbreak); - freetree(cond); } static void @@ -306,7 +297,6 @@ If(Symbol *lbreak, Symbol *lcont, Caselist *lswitch) } else { emit(OLABEL, lelse); } - freetree(np); } void @@ -369,7 +359,6 @@ stmt(Symbol *lbreak, Symbol *lcont, Caselist *lswitch) next(); np = expr(); emit(OPRINT, np); - freetree(np); return; } (*fun)(lbreak, lcont, lswitch);