aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2015-09-09 10:00:22 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-09-09 10:00:22 -0700
commit9a50174dbc25773fe9b1b582106fb752ff38eec2 (patch)
tree761170632717695ff50303c5a5908ce6205fdea5 /include
parentaf2533a165ae99f79416b730910731768b0a4ddf (diff)
Specialize SkOncePtr<T[]>.
SkOncePtr<T[]> is identical to SkOncePtr<T> except we'll default to delete[] for cleanup. CQ_EXTRA_TRYBOTS=client.skia:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-ASAN-Trybot BUG=skia: No public API changes. TBR=reed@google.com Review URL: https://codereview.chromium.org/1311893010
Diffstat (limited to 'include')
-rw-r--r--include/core/SkColorTable.h8
-rw-r--r--include/private/SkOncePtr.h4
2 files changed, 7 insertions, 5 deletions
diff --git a/include/core/SkColorTable.h b/include/core/SkColorTable.h
index ff2bf7cde2..cb613befb1 100644
--- a/include/core/SkColorTable.h
+++ b/include/core/SkColorTable.h
@@ -61,11 +61,9 @@ private:
// assumes ownership of colors (assumes it was allocated w/ malloc)
SkColorTable(SkPMColor* colors, int count, AllocatedWithMalloc);
- struct Free16BitCache { void operator()(uint16_t* cache) const { sk_free(cache); } };
-
- SkPMColor* fColors;
- SkOncePtr<uint16_t, Free16BitCache> f16BitCache;
- int fCount;
+ SkPMColor* fColors;
+ SkOncePtr<uint16_t[]> f16BitCache;
+ int fCount;
void init(const SkPMColor* colors, int count);
diff --git a/include/private/SkOncePtr.h b/include/private/SkOncePtr.h
index 40bea1a4c3..ee30d8f8db 100644
--- a/include/private/SkOncePtr.h
+++ b/include/private/SkOncePtr.h
@@ -40,6 +40,10 @@ private:
SkBaseOncePtr<T> fOnce;
};
+// If you ask for SkOncePtr<T[]>, we'll clean up with delete[] by default.
+template <typename T>
+class SkOncePtr<T[]> : public SkOncePtr<T, skstd::default_delete<T[]>> {};
+
/* TODO(mtklein): in next CL
typedef SkBaseOncePtr<void> SkOnceFlag;
#define SK_DECLARE_STATIC_ONCE(name) namespace {} static SkOnceFlag name