Index: src/core/SkData.cpp |
diff --git a/src/core/SkData.cpp b/src/core/SkData.cpp |
index fd963a9ff50b22aedf2d18f30ee6880e08afd598..176e93c47be2f98303ba849cbb0eda597d370e6c 100644 |
--- a/src/core/SkData.cpp |
+++ b/src/core/SkData.cpp |
@@ -48,16 +48,18 @@ size_t SkData::copyRange(size_t offset, size_t length, void* buffer) const { |
/////////////////////////////////////////////////////////////////////////////// |
-void SkData::NewEmptyImpl(SkData** empty) { |
- *empty = new SkData(NULL, 0, NULL, NULL); |
+static SkData* gEmptyDataRef = NULL; |
+static void cleanup_gEmptyDataRef() { gEmptyDataRef->unref(); } |
+ |
+void SkData::NewEmptyImpl(int) { |
+ gEmptyDataRef = new SkData(NULL, 0, NULL, NULL); |
} |
SkData* SkData::NewEmpty() { |
- static SkData* gEmptyRef; |
SK_DECLARE_STATIC_ONCE(once); |
- SkOnce(&once, SkData::NewEmptyImpl, &gEmptyRef); |
- gEmptyRef->ref(); |
- return gEmptyRef; |
+ SkOnce(&once, SkData::NewEmptyImpl, 0, cleanup_gEmptyDataRef); |
+ gEmptyDataRef->ref(); |
+ return gEmptyDataRef; |
} |
// assumes fPtr was allocated via sk_malloc |