Index: include/core/SkData.h |
diff --git a/include/core/SkData.h b/include/core/SkData.h |
index 4f0c213da9bc6f07c9e89f87f77831fb66e763f4..0e4a474e124f443356716314f97871729c1b54ee 100644 |
--- a/include/core/SkData.h |
+++ b/include/core/SkData.h |
@@ -168,7 +168,14 @@ private: |
SkData(size_t size); // inplace new/delete |
virtual ~SkData(); |
- virtual void internal_dispose() const SK_OVERRIDE; |
+ |
+ // Objects of this type are sometimes created in a custom fashion using sk_malloc_throw and |
+ // therefore must be sk_freed. We overload new to also call sk_malloc_throw so that memory |
+ // can be unconditionally released using sk_free in an overloaded delete. Overloading regular |
+ // new means we must also overload placement new. |
+ void* operator new(size_t size) { return sk_malloc_throw(size); } |
+ void* operator new(size_t, void* p) { return p; } |
+ void operator delete(void* p) { sk_free(p); } |
// Called the first time someone calls NewEmpty to initialize the singleton. |
friend SkData* sk_new_empty_data(); |