From 5a744b780190adbe6f210ffa4da9693b66d87afd Mon Sep 17 00:00:00 2001 From: mtklein Date: Mon, 14 Sep 2015 11:11:17 -0700 Subject: Have SkVarAlloc::alloc() use sk_malloc_throw. Very right, it's not prepared to handle return-NULL mallocs at all. BUG=530759 Review URL: https://codereview.chromium.org/1339093002 --- src/core/SkRecord.h | 2 +- src/core/SkVarAlloc.cpp | 8 ++++---- src/core/SkVarAlloc.h | 8 ++++---- src/gpu/GrBatchFontCache.cpp | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/core/SkRecord.h b/src/core/SkRecord.h index 933cccceb8..6893cb02ab 100644 --- a/src/core/SkRecord.h +++ b/src/core/SkRecord.h @@ -68,7 +68,7 @@ public: // Here T can be any class, not just those from SkRecords. Throws on failure. template T* alloc(size_t count = 1) { - return (T*)fAlloc.alloc(sizeof(T) * count, SK_MALLOC_THROW); + return (T*)fAlloc.alloc(sizeof(T) * count); } // Add a new command of type T to the end of this SkRecord. diff --git a/src/core/SkVarAlloc.cpp b/src/core/SkVarAlloc.cpp index f95370585d..840cf28347 100644 --- a/src/core/SkVarAlloc.cpp +++ b/src/core/SkVarAlloc.cpp @@ -18,9 +18,9 @@ struct SkVarAlloc::Block { Block* prev; char* data() { return (char*)(this + 1); } - static Block* Alloc(Block* prev, size_t size, unsigned flags) { + static Block* Alloc(Block* prev, size_t size) { SkASSERT(size >= sizeof(Block)); - Block* b = (Block*)sk_malloc_flags(size, flags); + Block* b = (Block*)sk_malloc_throw(size); b->prev = prev; return b; } @@ -49,7 +49,7 @@ SkVarAlloc::~SkVarAlloc() { } } -void SkVarAlloc::makeSpace(size_t bytes, unsigned flags) { +void SkVarAlloc::makeSpace(size_t bytes) { SkASSERT(SkIsAlignPtr(bytes)); size_t alloc = 1<data(); fRemaining = alloc - sizeof(Block); diff --git a/src/core/SkVarAlloc.h b/src/core/SkVarAlloc.h index 0d0984285b..3729bad105 100644 --- a/src/core/SkVarAlloc.h +++ b/src/core/SkVarAlloc.h @@ -19,12 +19,12 @@ public: ~SkVarAlloc(); - // Returns contiguous bytes aligned at least for pointers. You may pass SK_MALLOC_THROW, etc. - char* alloc(size_t bytes, unsigned sk_malloc_flags) { + // Returns contiguous bytes aligned at least for pointers. + char* alloc(size_t bytes) { bytes = SkAlignPtr(bytes); if (bytes > fRemaining) { - this->makeSpace(bytes, sk_malloc_flags); + this->makeSpace(bytes); } SkASSERT(bytes <= fRemaining); @@ -39,7 +39,7 @@ public: size_t approxBytesAllocated() const { return fBytesAllocated; } private: - void makeSpace(size_t bytes, unsigned flags); + void makeSpace(size_t bytes); size_t fBytesAllocated; diff --git a/src/gpu/GrBatchFontCache.cpp b/src/gpu/GrBatchFontCache.cpp index de8047b948..f3844cecba 100644 --- a/src/gpu/GrBatchFontCache.cpp +++ b/src/gpu/GrBatchFontCache.cpp @@ -178,7 +178,7 @@ GrGlyph* GrBatchTextStrike::generateGlyph(const SkGlyph& skGlyph, GrGlyph::Packe } GrMaskFormat format = scaler->getPackedGlyphMaskFormat(skGlyph); - GrGlyph* glyph = (GrGlyph*)fPool.alloc(sizeof(GrGlyph), SK_MALLOC_THROW); + GrGlyph* glyph = (GrGlyph*)fPool.alloc(sizeof(GrGlyph)); glyph->init(packed, bounds, format); fCache.add(glyph); return glyph; -- cgit v1.2.3