diff options
author | mtklein <mtklein@chromium.org> | 2014-10-13 13:17:56 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-10-13 13:17:56 -0700 |
commit | 148ec59001ca7d7e54aec580a048c6dd2a085991 (patch) | |
tree | ee310a6be5a0b53ac4ed05dd6907bd0d328dda6d /src/core/SkData.cpp | |
parent | 70242ace3b2ed06b33ee5ea5c9ac3aedea89b194 (diff) |
Require SK_DECLARE_STATIC_LAZY_PTR is used in global scope.
Function- or method- local scope isn't threadsafe; the pointer is generally
zero-initialized on first use in function scope (i.e. lazily... we have to go
deeper), but for globals we can be pretty sure the linker will do that for us.
BUG=skia:
No public API changes.
TBR=reed@google.com
Review URL: https://codereview.chromium.org/651723003
Diffstat (limited to 'src/core/SkData.cpp')
-rw-r--r-- | src/core/SkData.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/core/SkData.cpp b/src/core/SkData.cpp index 11cab7e98b..c5d10775f8 100644 --- a/src/core/SkData.cpp +++ b/src/core/SkData.cpp @@ -92,14 +92,13 @@ SkData* SkData::PrivateNewWithCopy(const void* srcOrNull, size_t length) { /////////////////////////////////////////////////////////////////////////////// -SkData* SkData::NewEmptyImpl() { - return new SkData(NULL, 0, NULL, NULL); -} +// As a template argument these must have external linkage. +SkData* sk_new_empty_data() { return new SkData(NULL, 0, NULL, NULL); } +namespace { void sk_unref_data(SkData* ptr) { return SkSafeUnref(ptr); } } -void SkData::DeleteEmpty(SkData* ptr) { SkDELETE(ptr); } +SK_DECLARE_STATIC_LAZY_PTR(SkData, empty, sk_new_empty_data, sk_unref_data); SkData* SkData::NewEmpty() { - SK_DECLARE_STATIC_LAZY_PTR(SkData, empty, NewEmptyImpl, DeleteEmpty); return SkRef(empty.get()); } |