Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(266)

Unified Diff: tests/DataRefTest.cpp

Issue 15675025: One allocation for an SkData which makes a copy. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Clean Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« include/core/SkWeakRefCnt.h ('K') | « src/pdf/SkPDFFont.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/DataRefTest.cpp
===================================================================
--- tests/DataRefTest.cpp (revision 9702)
+++ tests/DataRefTest.cpp (working copy)
@@ -229,11 +229,16 @@
static void* gGlobal;
-static void delete_int_proc(const void* ptr, size_t len, void* context) {
- int* data = (int*)ptr;
- SkASSERT(context == gGlobal);
- delete[] data;
-}
+struct DeleteIntFunctor {
+ explicit DeleteIntFunctor(void* context) : fContext(context) { }
+ void operator()(const void* ptr, size_t len) const {
+ int* data = (int*)ptr;
+ SkASSERT(fContext == gGlobal);
+ delete[] data;
+ }
+private:
+ void* fContext;
+};
static void assert_len(skiatest::Reporter* reporter, SkData* ref, size_t len) {
REPORTER_ASSERT(reporter, ref->size() == len);
@@ -299,7 +304,7 @@
SkAutoTUnref<SkData> r0(SkData::NewEmpty());
SkAutoTUnref<SkData> r1(SkData::NewWithCopy(str, strlen(str)));
SkAutoTUnref<SkData> r2(SkData::NewWithProc(new int[N], N*sizeof(int),
- delete_int_proc, gGlobal));
+ DeleteIntFunctor(gGlobal)));
SkAutoTUnref<SkData> r3(SkData::NewSubset(r1, 7, 6));
assert_len(reporter, r0, 0);
« include/core/SkWeakRefCnt.h ('K') | « src/pdf/SkPDFFont.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698