Class delete call unsized delete when size not known.

Some classes directly call global operator new to reserve space in
addition to the space the class will occupy. These clases must be
deleted with the unsized global operator new. If a build is configured
such that sized global operator new is called from a delete expression,
this must be overridden by such classes.

TBR=reed
Only affects private bits of SkData.

Change-Id: I797935db17a37aa8c2ca7b562a4ea65a7978a9f0
Reviewed-on: https://skia-review.googlesource.com/3678
Reviewed-by: Ben Wagner <bungeman@google.com>
Reviewed-by: Mike Klein <mtklein@chromium.org>
Commit-Queue: Ben Wagner <bungeman@google.com>
Commit-Queue: Mike Klein <mtklein@chromium.org>
This commit is contained in:
Ben Wagner 2016-10-19 17:15:44 -04:00 committed by Mike Klein
parent f4ace0124f
commit e1d6ff172e
2 changed files with 6 additions and 0 deletions

View File

@ -168,6 +168,9 @@ private:
explicit SkData(size_t size); // inplace new/delete
~SkData();
// Ensure the unsized delete is called.
void operator delete(void* p) { ::operator delete(p); }
// Called the first time someone calls NewEmpty to initialize the singleton.
friend SkData* sk_new_empty_data();

View File

@ -25,6 +25,9 @@ public:
return std::unique_ptr<SkDescriptor>(static_cast<SkDescriptor*>(::operator new (length)));
}
// Ensure the unsized delete is called.
void operator delete(void* p) { ::operator delete(p); }
void init() {
fLength = sizeof(SkDescriptor);
fCount = 0;