Bug 1038897: pop entries off the cache until its size reaches max cache size. Input read from corresponding pref is clamped to non-negative values (r=seth)

This commit is contained in:
Georgios Kontaxis 2014-07-18 18:47:39 -07:00
parent 73801da33e
commit ca277145d5

View File

@ -1031,6 +1031,7 @@ void imgLoader::GlobalInit()
sCacheMaxSize = cachesize;
else
sCacheMaxSize = 5 * 1024 * 1024;
sCacheMaxSize = sCacheMaxSize > 0 ? sCacheMaxSize : 0;
sMemReporter = new imgMemoryReporter();
RegisterStrongMemoryReporter(sMemReporter);
@ -1305,8 +1306,8 @@ void imgLoader::CheckCacheLimits(imgCacheTable &cache, imgCacheQueue &queue)
NS_ASSERTION(queue.GetSize() == 0,
"imgLoader::CheckCacheLimits -- incorrect cache size");
// Remove entries from the cache until we're back under our desired size.
while (queue.GetSize() >= sCacheMaxSize) {
// Remove entries from the cache until we're back at our desired max size.
while (queue.GetSize() > sCacheMaxSize) {
// Remove the first entry in the queue.
nsRefPtr<imgCacheEntry> entry(queue.Pop());