aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorBastien Bouclet2017-12-28 19:47:45 +0100
committerBastien Bouclet2017-12-28 21:18:51 +0100
commit2c8afb2bd25ed9992663f0fba0aeb2e43136c64f (patch)
tree0a1eca18e57338644d73b60b86c34f69a95f5f50 /common
parent26c096d39df27e8460af6ff8c28f381ca90e0422 (diff)
downloadscummvm-rg350-2c8afb2bd25ed9992663f0fba0aeb2e43136c64f.tar.gz
scummvm-rg350-2c8afb2bd25ed9992663f0fba0aeb2e43136c64f.tar.bz2
scummvm-rg350-2c8afb2bd25ed9992663f0fba0aeb2e43136c64f.zip
COMMON: Add a reset method to DisposablePtr
Diffstat (limited to 'common')
-rw-r--r--common/ptr.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/common/ptr.h b/common/ptr.h
index f592beb005..f3b2f3cbfa 100644
--- a/common/ptr.h
+++ b/common/ptr.h
@@ -302,6 +302,22 @@ public:
bool operator_bool() const { return _pointer != nullptr; }
/**
+ * Resets the pointer with the new value. Old object will be destroyed
+ */
+ void reset(PointerType o, DisposeAfterUse::Flag dispose) {
+ if (_dispose) D()(_pointer);
+ _pointer = o;
+ _dispose = dispose;
+ }
+
+ /**
+ * Clears the pointer. Old object will be destroyed
+ */
+ void reset() {
+ reset(nullptr, DisposeAfterUse::NO);
+ }
+
+ /**
* Returns the plain pointer value.
*
* @return the pointer the DisposablePtr manages