Mercurial > hg > index.cgi
changeset 93:5bf9edabd661
Squashed the remaining memory leaks revealed by valgrind
author | lost@l-w.ca |
---|---|
date | Wed, 22 Jun 2011 19:28:36 -0600 |
parents | 19ca3108a223 |
children | 61c084b2c727 |
files | lwasm/input.c lwasm/pass1.c lwasm/pseudo.c |
diffstat | 3 files changed, 10 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/lwasm/input.c Wed Jun 22 19:13:06 2011 -0600 +++ b/lwasm/input.c Wed Jun 22 19:28:36 2011 -0600 @@ -136,7 +136,7 @@ t -> data2 = 0; t -> next = IS; as -> input_data = t; - t -> filespec = lw_strdup(s); +// t -> filespec = lw_strdup(s); } void input_open(asmstate_t *as, char *s)
--- a/lwasm/pass1.c Wed Jun 22 19:13:06 2011 -0600 +++ b/lwasm/pass1.c Wed Jun 22 19:28:36 2011 -0600 @@ -55,7 +55,7 @@ line_t *cl; char *p1; int stspace; - char *tok, *sym; + char *tok, *sym = NULL; int opnum; int lc = 1; int nomacro; @@ -63,6 +63,8 @@ for (;;) { nomacro = 0; + if (sym) + lw_free(sym); sym = NULL; line = input_readline(as); if (!line) @@ -247,6 +249,7 @@ if (*tok) { // look up operation code + lw_free(sym); sym = lw_strndup(tok, p1 - tok); for (; *p1 && isspace(*p1); p1++) /* do nothing */ ; @@ -350,8 +353,6 @@ } linedone: - lw_free(sym); - if (!as -> skipcond && !as -> inmacro) { if (cl -> sym && cl -> symset == 0) @@ -369,6 +370,10 @@ } nextline: + if (sym) + lw_free(sym); + sym = NULL; + lw_free(line); // if we've hit the "end" bit, finish out