From e49d57117507903a7d912218b4e1ebd2f15bbbd7 Mon Sep 17 00:00:00 2001 From: "reed@google.com" Date: Wed, 19 Jan 2011 14:30:26 +0000 Subject: [PATCH] fix fEntryCount when we purge a cache entry (bug caught by our validate()) git-svn-id: http://skia.googlecode.com/svn/trunk@712 2bbb7eff-a529-9590-31e7-b0007b416f81 --- src/effects/SkBitmapCache.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/effects/SkBitmapCache.cpp b/src/effects/SkBitmapCache.cpp index bcbde9239..2a3f87a7f 100644 --- a/src/effects/SkBitmapCache.cpp +++ b/src/effects/SkBitmapCache.cpp @@ -105,11 +105,11 @@ bool SkBitmapCache::find(const void* buffer, size_t size, SkBitmap* bm) const { void SkBitmapCache::add(const void* buffer, size_t len, const SkBitmap& bm) { AutoValidate av(this); - + if (fEntryCount == fMaxEntries) { - if (fTail) { - delete this->detach(fTail); - } + SkASSERT(fTail); + delete this->detach(fTail); + fEntryCount -= 1; } Entry* entry = new Entry(buffer, len, bm); @@ -123,7 +123,7 @@ void SkBitmapCache::add(const void* buffer, size_t len, const SkBitmap& bm) { void SkBitmapCache::validate() const { SkASSERT(fEntryCount >= 0 && fEntryCount <= fMaxEntries); - + if (fEntryCount > 0) { SkASSERT(NULL == fHead->fPrev); SkASSERT(NULL == fTail->fNext); @@ -141,7 +141,7 @@ void SkBitmapCache::validate() const { entry = entry->fNext; } SkASSERT(count == fEntryCount); - + entry = fTail; while (entry) { count -= 1; @@ -151,7 +151,7 @@ void SkBitmapCache::validate() const { } else { SkASSERT(NULL == fHead); SkASSERT(NULL == fTail); - } + } } #endif