aboutsummaryrefslogtreecommitdiff
path: root/file_loader.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2021-01-13 01:48:36 -0800
committerBruce Hill <bruce@bruce-hill.com>2021-01-13 01:48:36 -0800
commit45d7aff47545f52136487fbb5b06cdcf716cbe9f (patch)
tree38140eaa9d47cea8276e06cec93f0cb2988eae8d /file_loader.c
parent7e4b287d9bd904aaf9cc2bf77cdd456194130e99 (diff)
Major overhaul of some of the memory tracking code, as well as some
cleanup of the compilation code.
Diffstat (limited to 'file_loader.c')
-rw-r--r--file_loader.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/file_loader.c b/file_loader.c
index 749e985..27f871f 100644
--- a/file_loader.c
+++ b/file_loader.c
@@ -124,10 +124,12 @@ void destroy_file(file_t **f)
xfree(&((*f)->filename));
(*f)->filename = NULL;
}
+
if ((*f)->lines) {
xfree(&((*f)->lines));
(*f)->lines = NULL;
}
+
if ((*f)->contents) {
if ((*f)->mmapped) {
munmap((*f)->contents, (size_t)((*f)->end - (*f)->contents));
@@ -136,6 +138,14 @@ void destroy_file(file_t **f)
}
(*f)->contents = NULL;
}
+
+ while ((*f)->ops) {
+ allocated_op_t *tofree = (*f)->ops;
+ (*f)->ops = tofree->next;
+ memset(tofree, 'A', sizeof(allocated_op_t)); // Sentinel
+ xfree(&tofree);
+ }
+
xfree(f);
}