summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--assemble.c34
1 files changed, 13 insertions, 21 deletions
diff --git a/assemble.c b/assemble.c
index 1ff88df..6397173 100644
--- a/assemble.c
+++ b/assemble.c
@@ -359,10 +359,11 @@ void assemble(line *ln, bytecount *bc, uint8_t dbg) {
}
}
-static inline void free_tokens(token *t, uint16_t count) {
+static inline void free_tokens(token *t) {
token *tok;
- for (; t != NULL && t >= tok; t = t->next) {
+ while (t != NULL) {
tok = t;
+ t = t->next;
free(tok);
}
}
@@ -370,32 +371,22 @@ static inline void free_tokens(token *t, uint16_t count) {
void free_lines() {
line *l = lines;
line *ln;
- for (; l != NULL && l >= ln; l = l->next) {
- free_tokens(l->tok, l->count);
+ while (l != NULL) {
+ free_tokens(l->tok);
ln = l;
+ l = l->next;
free(ln);
}
}
-void free_locals(symbol *s) {
+void free_symbols(symbol *s) {
symbol *sym;
- for (; s != NULL && s >= sym; s = s->next) {
- sym = s;
- if (sym->name != NULL) {
- free(sym->name);
- }
- free(sym);
- }
-}
-
-void free_symbols() {
- symbol *s = symbols;
- symbol *sym = symbols;
- for (; s != NULL && s >= sym; s = s->next) {
+ while (s != NULL) {
if (s->local) {
- free_locals(s->local);
+ free_symbols(s->local);
}
sym = s;
+ s = s->next;
if (sym->name != NULL) {
free(sym->name);
}
@@ -406,8 +397,9 @@ void free_symbols() {
static inline void free_fixups() {
fixup *f = fixups;
fixup *fix;
- for (; f != NULL && f >= fix; f = f->next) {
+ while (f != NULL) {
fix = f;
+ f = f->next;
free(fix);
}
}
@@ -418,7 +410,7 @@ void cleanup() {
free_lines();
}
if (symbols) {
- free_symbols();
+ free_symbols(symbols);
}
if (fixups) {
free_fixups();