aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/core
diff options
context:
space:
mode:
authorGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-08-09 15:30:41 +0000
committerGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-08-09 15:30:41 +0000
commita44f7003e5f9d1353bc9274268fb5302e69fc94a (patch)
tree472bd5a0a4fab051f9ee2f9c812192d6694d4343 /include/core
parent47ae725dbd03cecba737d6445a7faa3241135728 (diff)
Fix some ref leaks
Review URL: http://codereview.appspot.com/4837068/ git-svn-id: http://skia.googlecode.com/svn/trunk@2082 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/core')
-rw-r--r--include/core/SkRefCnt.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/include/core/SkRefCnt.h b/include/core/SkRefCnt.h
index 6dbf72037c..4c9376b44a 100644
--- a/include/core/SkRefCnt.h
+++ b/include/core/SkRefCnt.h
@@ -101,11 +101,16 @@ template <typename T> static inline void SkSafeUnref(T* obj) {
*/
template <typename T> class SkAutoTUnref : SkNoncopyable {
public:
- SkAutoTUnref(T* obj) : fObj(obj) {}
+ explicit SkAutoTUnref(T* obj = NULL) : fObj(obj) {}
~SkAutoTUnref() { SkSafeUnref(fObj); }
T* get() const { return fObj; }
+ void reset(T* obj) {
+ SkSafeUnref(fObj);
+ fObj = obj;
+ }
+
/**
* Return the hosted object (which may be null), transferring ownership.
* The reference count is not modified, and the internal ptr is set to NULL