summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
Diffstat (limited to 'base')
-rw-r--r--base/ref_counted.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/base/ref_counted.h b/base/ref_counted.h
index 013bd66..79f9f55 100644
--- a/base/ref_counted.h
+++ b/base/ref_counted.h
@@ -200,6 +200,17 @@ class scoped_refptr {
operator T*() const { return ptr_; }
T* operator->() const { return ptr_; }
+ // Release a pointer.
+ // The return value is the current pointer held by this object.
+ // If this object holds a NULL pointer, the return value is NULL.
+ // After this operation, this object will hold a NULL pointer,
+ // and will not own the object any more.
+ T* release() {
+ T* retVal = ptr_;
+ ptr_ = NULL;
+ return retVal;
+ }
+
scoped_refptr<T>& operator=(T* p) {
// AddRef first so that self assignment should work
if (p)