Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: src/core/SkScaledImageCache.cpp

Issue 107443009: Address memory leak in SkScaledImageCache (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Added comment Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkScaledImageCache.h" 8 #include "SkScaledImageCache.h"
9 #include "SkMipMap.h" 9 #include "SkMipMap.h"
10 #include "SkOnce.h" 10 #include "SkOnce.h"
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 421
422 422
423 //////////////////////////////////////////////////////////////////////////////// 423 ////////////////////////////////////////////////////////////////////////////////
424 /** 424 /**
425 This private method is the fully general record adder. All other 425 This private method is the fully general record adder. All other
426 record adders should call this funtion. */ 426 record adders should call this funtion. */
427 SkScaledImageCache::ID* SkScaledImageCache::addAndLock(SkScaledImageCache::Rec* rec) { 427 SkScaledImageCache::ID* SkScaledImageCache::addAndLock(SkScaledImageCache::Rec* rec) {
428 SkASSERT(rec); 428 SkASSERT(rec);
429 // See if we already have this key (racy inserts, etc.) 429 // See if we already have this key (racy inserts, etc.)
430 Rec* existing = this->findAndLock(rec->fKey); 430 Rec* existing = this->findAndLock(rec->fKey);
431 if (existing != NULL) { 431 if (NULL != existing) {
432 // Since we already have a matching entry, just delete the new one and r eturn.
433 // Call sites cannot assume the passed in object will live past this cal l.
434 SkDELETE(rec);
432 return rec_to_id(existing); 435 return rec_to_id(existing);
433 } 436 }
434 437
435 this->addToHead(rec); 438 this->addToHead(rec);
436 SkASSERT(1 == rec->fLockCount); 439 SkASSERT(1 == rec->fLockCount);
437 #ifdef USE_HASH 440 #ifdef USE_HASH
438 SkASSERT(fHash); 441 SkASSERT(fHash);
439 fHash->add(rec); 442 fHash->add(rec);
440 #endif 443 #endif
441 // We may (now) be overbudget, so see if we need to purge something. 444 // We may (now) be overbudget, so see if we need to purge something.
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
790 return SkScaledImageCache::GetBytesUsed(); 793 return SkScaledImageCache::GetBytesUsed();
791 } 794 }
792 795
793 size_t SkGraphics::GetImageCacheByteLimit() { 796 size_t SkGraphics::GetImageCacheByteLimit() {
794 return SkScaledImageCache::GetByteLimit(); 797 return SkScaledImageCache::GetByteLimit();
795 } 798 }
796 799
797 size_t SkGraphics::SetImageCacheByteLimit(size_t newLimit) { 800 size_t SkGraphics::SetImageCacheByteLimit(size_t newLimit) {
798 return SkScaledImageCache::SetByteLimit(newLimit); 801 return SkScaledImageCache::SetByteLimit(newLimit);
799 } 802 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698