From 9cb8e4f83b49355610134b152df129b2f68ce9fe Mon Sep 17 00:00:00 2001 From: mrb0nk500 Date: Sat, 8 May 2021 12:22:25 -0400 Subject: Start implementing whole file lexing. This will eventually replace the per-line lexer. --- assemble.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'assemble.c') diff --git a/assemble.c b/assemble.c index b51fd5c..cdd82d6 100644 --- a/assemble.c +++ b/assemble.c @@ -1304,6 +1304,23 @@ static void free_fixups(fixup *f) { } } +void free_strlns(strln *root) { + strln *line; + if (root != NULL) { + line = root; + root = root->next; + if (line->str != NULL) { + free(line->str); + } + line->blanks = 0; + line->prev = NULL; + line->next = NULL; + free(line); + line = NULL; + free_strlns(root); + } +} + uint64_t get_tokmem(token *t) { uint64_t i = 0; for (; t; t = t->next, i++); @@ -1324,15 +1341,23 @@ void cleanup() { /*fix_symtree(lines);*/ free_lines(lines); lines = NULL; + last_line = NULL; } if (symbols) { /*print_symtree(symbols, 0);*/ free_symbols(symbols); symbols = NULL; + last_sym = NULL; } if (fixups) { free_fixups(fixups); fixups = NULL; + last_fix = NULL; + } + if (first_strln) { + free_strlns(first_strln); + first_strln = NULL; + last_strln = NULL; } while (i < stridx || i < comidx) { if (i < stridx && string[i]) { -- cgit v1.2.3-13-gbd6f