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

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: 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..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();
« 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