diff options
author | 2014-11-12 10:09:10 -0800 | |
---|---|---|
committer | 2014-11-12 10:09:11 -0800 | |
commit | 391e318b3d31669ecef5306cb279618c121e45af (patch) | |
tree | e5168057a3693c85dd5969f087b08502a0c32599 /tests | |
parent | 88300a555f03df7d1d0d480b870388b42e032657 (diff) |
Fix memory leak in BitmapHeapTest
BUG=skia:
Review URL: https://codereview.chromium.org/715383003
Diffstat (limited to 'tests')
-rw-r--r-- | tests/BitmapHeapTest.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/tests/BitmapHeapTest.cpp b/tests/BitmapHeapTest.cpp index f3385644bd..c7d097278b 100644 --- a/tests/BitmapHeapTest.cpp +++ b/tests/BitmapHeapTest.cpp @@ -17,9 +17,15 @@ struct SimpleFlatController : public SkFlatController { SimpleFlatController() : SkFlatController() {} - virtual void* allocThrow(size_t bytes) SK_OVERRIDE { return sk_malloc_throw(bytes); } - virtual void unalloc(void* ptr) SK_OVERRIDE { sk_free(ptr); } + ~SimpleFlatController() { fAllocations.freeAll(); } + virtual void* allocThrow(size_t bytes) SK_OVERRIDE { + fAllocations.push(sk_malloc_throw(bytes)); + return fAllocations.top(); + } + virtual void unalloc(void*) SK_OVERRIDE { } void setBitmapStorage(SkBitmapHeap* h) { this->setBitmapHeap(h); } +private: + SkTDArray<void*> fAllocations; }; struct SkShaderTraits { |