| Index: src/core/SkData.cpp
|
| diff --git a/src/core/SkData.cpp b/src/core/SkData.cpp
|
| index 8d6156c7f2969bca3413eeb766482b40ab7c4ca8..56c1256d7524fe8b09ffac0cff30f5d4e2aeb4a1 100644
|
| --- a/src/core/SkData.cpp
|
| +++ b/src/core/SkData.cpp
|
| @@ -8,6 +8,7 @@
|
| #include "SkData.h"
|
| #include "SkFlattenableBuffers.h"
|
| #include "SkOSFile.h"
|
| +#include "SkOnce.h"
|
|
|
| SK_DEFINE_INST_COUNT(SkData)
|
|
|
| @@ -49,11 +50,14 @@ 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);
|
| +}
|
| +
|
| SkData* SkData::NewEmpty() {
|
| static SkData* gEmptyRef;
|
| - if (NULL == gEmptyRef) {
|
| - gEmptyRef = new SkData(NULL, 0, NULL, NULL);
|
| - }
|
| + SK_DECLARE_STATIC_ONCE(once);
|
| + SkOnce(&once, SkData::NewEmptyImpl, &gEmptyRef);
|
| gEmptyRef->ref();
|
| return gEmptyRef;
|
| }
|
|
|