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

Unified Diff: include/core/SkData.h

Issue 737093002: Stop overloading internal_dispose in SkTextBlob and SkData (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: ARGGGGGGHHHH Created 6 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | include/core/SkTextBlob.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
« no previous file with comments | « no previous file | include/core/SkTextBlob.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698