From 14123882c2b915f3332fed5c83ef64ded0a25cac Mon Sep 17 00:00:00 2001 From: Peter Evans Date: Wed, 7 Mar 2018 20:54:46 -0600 Subject: [PATCH] Use vm_di_get for file streams to close them --- src/main.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main.c b/src/main.c index 0c97a49..9842a23 100644 --- a/src/main.c +++ b/src/main.c @@ -62,12 +62,15 @@ init(int argc, char **argv) static void finish() { - // Close any file sources we had opened - for (int i = 1; i <= OPTION_MAX_DISKS; i++) { - FILE *stream = option_get_input(i); + FILE *stream[3]; - if (stream != NULL) { - fclose(stream); + stream[0] = (FILE *)vm_di_get(VM_DISK1); + stream[1] = (FILE *)vm_di_get(VM_DISK2); + stream[2] = (FILE *)vm_di_get(VM_DISASM_LOG); + + for (int i = 0; i < 3; i++) { + if (stream[i]) { + fclose(stream[i]); } }