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

Unified Diff: include/core/SkTemplates.h

Issue 13831011: use SkAutoTDelete instead of SkTScopedPtr (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 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 | « bench/GrMemoryPoolBench.cpp ('k') | tests/GrMemoryPoolTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkTemplates.h
===================================================================
--- include/core/SkTemplates.h (revision 8748)
+++ include/core/SkTemplates.h (working copy)
@@ -80,16 +80,22 @@
T* fObj;
};
-// See also SkTScopedPtr.
template <typename T> class SkAutoTDelete : SkNoncopyable {
public:
- SkAutoTDelete(T* obj) : fObj(obj) {}
+ SkAutoTDelete(T* obj = NULL) : fObj(obj) {}
~SkAutoTDelete() { delete fObj; }
T* get() const { return fObj; }
T& operator*() const { SkASSERT(fObj); return *fObj; }
T* operator->() const { SkASSERT(fObj); return fObj; }
+ void reset(T* obj) {
+ if (fObj != obj) {
+ delete fObj;
+ fObj = obj;
+ }
+ }
+
/**
* Delete the owned object, setting the internal pointer to NULL.
*/
« no previous file with comments | « bench/GrMemoryPoolBench.cpp ('k') | tests/GrMemoryPoolTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698