BOOLEAN CacheReleaseMemory(ULONG MinimumAmountToRelease) { ULONG AmountReleased; TRACE("CacheReleaseMemory() MinimumAmountToRelease = %d\n", MinimumAmountToRelease); // If we aren't initialized yet then they can't do this if (CacheManagerInitialized == FALSE) { return FALSE; } // Loop through and try to free the requested amount of memory for (AmountReleased=0; AmountReleased<MinimumAmountToRelease; ) { // Try to free a block // If this fails then break out of the loop if (!CacheInternalFreeBlock(&CacheManagerDrive)) { break; } // It succeeded so increment the amount of memory we have freed AmountReleased += CacheManagerDrive.BlockSize * CacheManagerDrive.BytesPerSector; } // Return status return (AmountReleased >= MinimumAmountToRelease); }
VOID CacheInternalCheckCacheSizeLimits(PCACHE_DRIVE CacheDrive) { SIZE_T NewCacheSize; TRACE("CacheInternalCheckCacheSizeLimits()\n"); // Calculate the size of the cache if we added a block NewCacheSize = (CacheBlockCount + 1) * (CacheDrive->BlockSize * CacheDrive->BytesPerSector); // Check the new size against the cache size limit if (NewCacheSize > CacheSizeLimit) { CacheInternalFreeBlock(CacheDrive); CacheInternalDumpBlockList(CacheDrive); } }