Chromium Code Reviews| Index: include/core/SkData.h |
| diff --git a/include/core/SkData.h b/include/core/SkData.h |
| index 4f0c213da9bc6f07c9e89f87f77831fb66e763f4..c24610fea2199dc07a8764c7369ab5341e37b3b8 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 unconditionally released using sk_free in and overloaded delete. Overloading regular |
|
mtklein
2014/11/19 21:56:59
and -> an
bsalomon
2014/11/20 14:49:57
Done, and also asserted that text blobs are always
|
| + // 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(); |