shithub: scc

Download patch

ref: f41175b80c5d599aba9fa70611adf5e94bf4c6e1
parent: 68ccb5a199aa86efb8b07f550a64860cb5da950d
author: Roberto E. Vargas Caballero <[email protected]>
date: Sun May 10 14:16:12 EDT 2015

Free trees after emit them

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

--- a/cc1/code.c
+++ b/cc1/code.c
@@ -251,6 +251,7 @@
 
 	emitnode(np);
 	putchar('\n');
+	freetree(np);
 }
 
 static void
@@ -261,6 +262,7 @@
 	emitnode(np);
 	printf("\tk%c\n", np->type->letter);
 	fflush(stdout);
+	freetree(np);
 }
 
 static void
--- a/cc1/stmt.c
+++ b/cc1/stmt.c
@@ -43,7 +43,6 @@
 	}
 
 	expect(';');
-	freetree(np);
 }
 
 static Node *
@@ -85,7 +84,6 @@
 	emit(OEXPR, np);
 	emit(OELOOP, NULL);
 	emit(OLABEL, end);
-	freetree(np);
 }
 
 static void
@@ -118,9 +116,6 @@
 	emit(OEXPR, econd);
 	emit(OELOOP, NULL);
 	emit(OLABEL, end);
-	freetree(einit);
-	freetree(econd);
-	freetree(einc);
 }
 
 static void
@@ -141,7 +136,6 @@
 	emit(OEXPR, np);
 	emit(OELOOP, NULL);
 	emit(OLABEL, end);
-	freetree(np);
 }
 
 static void
@@ -165,7 +159,6 @@
 	}
 	emit(ORET, tp);
 	emit(OEXPR, np);
-	freetree(np);
 }
 
 static void
@@ -244,13 +237,11 @@
 		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 @@
 	} else {
 		emit(OLABEL, lelse);
 	}
-	freetree(np);
 }
 
 void
@@ -369,7 +359,6 @@
 		next();
 		np = expr();
 		emit(OPRINT, np);
-		freetree(np);
 		return;
 	}
 	(*fun)(lbreak, lcont, lswitch);