summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEero Tamminen <oak@helsinkinet.fi>2022-08-01 18:15:14 (GMT)
committerEero Tamminen <oak@helsinkinet.fi>2022-08-18 22:11:22 (GMT)
commita10573d2e6bc6e885e3d28330f88857f78a81e91 (patch)
treecef4c3ec6efa5d8a85b1ac139da56fbba20213d2
parent08bc257aa4915663fbf76872d22d6fdf881f58cd (diff)
downloadhatari-a10573d2e6bc6e885e3d28330f88857f78a81e91.zip
hatari-a10573d2e6bc6e885e3d28330f88857f78a81e91.tar.gz
Clear DTA cache on GEMDOS HD changes, and free it on exit
-rw-r--r--src/gemdos.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/src/gemdos.c b/src/gemdos.c
index bf2d22d..d23c5eb 100644
--- a/src/gemdos.c
+++ b/src/gemdos.c
@@ -392,6 +392,23 @@ static void GemDOS_ClearAllInternalDTAs(void)
DTAIndex = 0;
}
+/**
+ * Free all DTA cache structures
+ */
+static void GemDOS_FreeAllInternalDTAs(void)
+{
+ int i;
+ for(i = 0; i < DTACount; i++)
+ {
+ ClearInternalDTA(i);
+ }
+ if (InternalDTAs)
+ {
+ free(InternalDTAs);
+ InternalDTAs = NULL;
+ }
+ DTAIndex = 0;
+}
/*-----------------------------------------------------------------------*/
/**
@@ -527,10 +544,6 @@ static void GemDOS_ClearAllFileHandles(void)
void GemDOS_Init(void)
{
bInitGemDOS = false;
-
- GemDOS_ClearAllFileHandles();
- GemDOS_ClearAllInternalDTAs();
-
}
/*-----------------------------------------------------------------------*/
@@ -696,6 +709,9 @@ void GemDOS_InitDrives(void)
int ImagePartitions;
bool bMultiPartitions;
+ GemDOS_ClearAllFileHandles();
+ GemDOS_ClearAllInternalDTAs();
+
bMultiPartitions = GemDOS_DetermineMaxPartitions(&nMaxDrives);
/* initialize data for harddrive emulation: */
@@ -791,6 +807,8 @@ void GemDOS_UnInitDrives(void)
{
int i;
+ GemDOS_FreeAllInternalDTAs();
+
GemDOS_Reset(); /* Close all open files on emulated drive */
if (GEMDOS_EMU_ON)