aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Schickel2008-07-29 09:16:53 +0000
committerJohannes Schickel2008-07-29 09:16:53 +0000
commit290f76a62352e741acd5888574cb30831c39da5d (patch)
treeb1c8a20c7fc5c199f741e8eac623e6918ec4fb1b
parent598394e5b88f8513b9f5d9ee841e5bc2882f5d6c (diff)
downloadscummvm-rg350-290f76a62352e741acd5888574cb30831c39da5d.tar.gz
scummvm-rg350-290f76a62352e741acd5888574cb30831c39da5d.tar.bz2
scummvm-rg350-290f76a62352e741acd5888574cb30831c39da5d.zip
Added a reset method to SharedPtr, which allows NULLifying it.
svn-id: r33400
-rw-r--r--common/ptr.h10
-rw-r--r--test/common/ptr.h3
2 files changed, 13 insertions, 0 deletions
diff --git a/common/ptr.h b/common/ptr.h
index eea3c39882..9879db28a6 100644
--- a/common/ptr.h
+++ b/common/ptr.h
@@ -171,6 +171,16 @@ public:
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.
* This should just be used for debugging purposes.
*/
diff --git a/test/common/ptr.h b/test/common/ptr.h
index 11ed52d4b9..986330057c 100644
--- a/test/common/ptr.h
+++ b/test/common/ptr.h
@@ -61,6 +61,9 @@ class PtrTestSuite : public CxxTest::TestSuite
TS_ASSERT(p1 != 0);
TS_ASSERT(p2 == 0);
+
+ p1.reset();
+ TS_ASSERT(!p1);
}
struct A {