diff options
author | David Phillips <david@sighup.nz> | 2019-08-04 14:21:05 +1200 |
---|---|---|
committer | David Phillips <david@sighup.nz> | 2019-08-04 14:24:50 +1200 |
commit | 4b1f9e2cb436e74ce6084dbc35df5f052cb701bf (patch) | |
tree | 201bf4d3cf1120ad0e9a8d3fe7b1a95c2fd3333d /assembler.c | |
parent | 1c8e50028e15facaa4d31992bfc6cab9d10832e6 (diff) | |
download | toy-cpu-assembler-4b1f9e2cb436e74ce6084dbc35df5f052cb701bf.tar.xz |
Wrap tests in valgrind, clean up memory leaks
Diffstat (limited to 'assembler.c')
-rw-r--r-- | assembler.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/assembler.c b/assembler.c index 7ae699d..bd94c33 100644 --- a/assembler.c +++ b/assembler.c @@ -1,4 +1,5 @@ #include <stdio.h> +#include <stdlib.h> #include <stdint.h> #include <string.h> @@ -63,6 +64,7 @@ int main(int argc, char **argv) if ((tokens = lex(path_in, fin, &tok_count)) == NULL) return error_ret; + fclose(fin); debug("Lexed.\n"); /* FIXME package these things into `tok_result`, `parse_result` etc */ @@ -82,6 +84,9 @@ int main(int argc, char **argv) if ((ret = output_bin(fout, labels, labels_count, insts, insts_count))) return error_ret && ret; + parse_free(insts, insts_count, labels, labels_count); + lex_free(tokens, tok_count); + fclose(fout); debug("Output.\n"); return 0; |