Index: base/scoped_ptr.h |
diff --git a/base/scoped_ptr.h b/base/scoped_ptr.h |
index 88ee41be94d5b8b880a6bb0c4ad95022b7425952..5d52dd1482f7c070b795f961668ea7af49db672a 100644 |
--- a/base/scoped_ptr.h |
+++ b/base/scoped_ptr.h |
@@ -122,6 +122,20 @@ class scoped_ptr { |
return retVal; |
} |
+ // Gets a pointer to the pointer. |
+ // Useful in case where we need to pass this pointer to pointer to |
+ // a function and the function fills the pointer. |
+ // If pointer_to were unavailable then we would have to |
+ // do some thing like: C* p; GetMeTheObject(&p); scoped_ptr sp(p); |
+ // With this we can just call GetMeTheObject(sp.pointer_to()) |
+ C** pointer_to() { |
+ CHECK(ptr_ == NULL);// we could do a reset here which would release |
+ // pointer but cause subtle bugs difficult to track |
+ // down. So instead crash right away. |
+ |
+ return &ptr_; |
+ } |
+ |
private: |
C* ptr_; |