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

Unified Diff: src/record/SkRecords.h

Issue 248053008: Proof of adoption in SkRecord::replace. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 8 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
« no previous file with comments | « src/record/SkRecordOpts.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/record/SkRecords.h
diff --git a/src/record/SkRecords.h b/src/record/SkRecords.h
index 8b96e8d91387873488ca468c8fd28921e1e867b6..bfa15496f31746284dfdc1358baaa2f68a421997 100644
--- a/src/record/SkRecords.h
+++ b/src/record/SkRecords.h
@@ -133,7 +133,12 @@ template <typename T>
class Adopted : SkNoncopyable {
public:
Adopted(T* ptr) : fPtr(ptr) { SkASSERT(fPtr); }
- ~Adopted() { fPtr->~T(); }
+ Adopted(Adopted* source) {
+ // Transfer ownership from source to this.
+ fPtr = source->fPtr;
+ source->fPtr = NULL;
+ }
+ ~Adopted() { if (fPtr) fPtr->~T(); }
ACT_AS_PTR(fPtr);
private:
@@ -142,9 +147,10 @@ private:
// PODArray doesn't own the pointer's memory, and we assume the data is POD.
template <typename T>
-class PODArray : SkNoncopyable {
+class PODArray {
public:
PODArray(T* ptr) : fPtr(ptr) {}
+ // Default copy and assign.
ACT_AS_PTR(fPtr);
private:
« no previous file with comments | « src/record/SkRecordOpts.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698