Added a reset method to SharedPtr, which allows NULLifying it.
svn-id: r33400
This commit is contained in:
parent
598394e5b8
commit
290f76a623
2 changed files with 13 additions and 0 deletions
10
common/ptr.h
10
common/ptr.h
|
@ -170,6 +170,16 @@ public:
|
||||||
*/
|
*/
|
||||||
bool unique() const { return refCount() == 1; }
|
bool unique() const { return refCount() == 1; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resets the SharedPtr object to a NULL pointer.
|
||||||
|
*/
|
||||||
|
void reset() {
|
||||||
|
decRef();
|
||||||
|
_deletion = 0;
|
||||||
|
_refCount = 0;
|
||||||
|
_pointer = 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of references to the assigned pointer.
|
* Returns the number of references to the assigned pointer.
|
||||||
* This should just be used for debugging purposes.
|
* This should just be used for debugging purposes.
|
||||||
|
|
|
@ -61,6 +61,9 @@ class PtrTestSuite : public CxxTest::TestSuite
|
||||||
|
|
||||||
TS_ASSERT(p1 != 0);
|
TS_ASSERT(p1 != 0);
|
||||||
TS_ASSERT(p2 == 0);
|
TS_ASSERT(p2 == 0);
|
||||||
|
|
||||||
|
p1.reset();
|
||||||
|
TS_ASSERT(!p1);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct A {
|
struct A {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue