[FREELDR] Diverse enhancements.
[reactos.git] / boot / freeldr / freeldr / cache / cache.c
index b19ebe9..dee293a 100644 (file)
@@ -42,10 +42,10 @@ BOOLEAN CacheInitializeDrive(UCHAR DriveNumber)
     // If we already have a cache for this drive then
     // by all means lets keep it, unless it is a removable
     // drive, in which case we'll invalidate the cache
-    if ((CacheManagerInitialized == TRUE) &&
+    if ((CacheManagerInitialized) &&
         (DriveNumber == CacheManagerDrive.DriveNumber) &&
         (DriveNumber >= 0x80) &&
-        (CacheManagerDataInvalid != TRUE))
+        (!CacheManagerDataInvalid))
     {
         return TRUE;
     }
@@ -72,8 +72,8 @@ BOOLEAN CacheInitializeDrive(UCHAR DriveNumber)
                                                CACHE_BLOCK,
                                                ListEntry);
 
-            MmHeapFree(NextCacheBlock->BlockData);
-            MmHeapFree(NextCacheBlock);
+            FrLdrTempFree(NextCacheBlock->BlockData, TAG_CACHE_DATA);
+            FrLdrTempFree(NextCacheBlock, TAG_CACHE_BLOCK);
         }
     }
 
@@ -93,9 +93,9 @@ BOOLEAN CacheInitializeDrive(UCHAR DriveNumber)
     CacheBlockCount = 0;
     CacheSizeLimit = TotalPagesInLookupTable / 8 * MM_PAGE_SIZE;
     CacheSizeCurrent = 0;
-    if (CacheSizeLimit < (64 * 1024))
+    if (CacheSizeLimit > TEMP_HEAP_SIZE - (128 * 1024))
     {
-        CacheSizeLimit = (64 * 1024);
+        CacheSizeLimit = TEMP_HEAP_SIZE - (128 * 1024);
     }
 
     CacheManagerInitialized = TRUE;
@@ -133,7 +133,7 @@ BOOLEAN CacheReadDiskSectors(UCHAR DiskNumber, ULONGLONG StartSector, ULONG Sect
     }
 
     //
-    // Caculate which blocks we must cache
+    // Calculate which blocks we must cache
     //
     StartBlock = (ULONG)(StartSector / CacheManagerDrive.BlockSize);
     SectorOffsetInStartBlock = (ULONG)(StartSector % CacheManagerDrive.BlockSize);
@@ -263,7 +263,7 @@ BOOLEAN CacheForceDiskSectorsIntoCache(UCHAR DiskNumber, ULONGLONG StartSector,
     }
 
     //
-    // Caculate which blocks we must cache
+    // Calculate which blocks we must cache
     //
     StartBlock = StartSector / CacheManagerDrive.BlockSize;
     EndBlock = (StartSector + SectorCount) / CacheManagerDrive.BlockSize;