aboutsummaryrefslogtreecommitdiff
path: root/common/ptr.h
diff options
context:
space:
mode:
Diffstat (limited to 'common/ptr.h')
-rw-r--r--common/ptr.h17
1 files changed, 14 insertions, 3 deletions
diff --git a/common/ptr.h b/common/ptr.h
index 7307038936..383b3ee15d 100644
--- a/common/ptr.h
+++ b/common/ptr.h
@@ -242,15 +242,17 @@ public:
*/
operator bool() const { return _pointer != 0; }
+ void deletePointer() { delete _pointer; }
+
~ScopedPtr() {
- delete _pointer;
+ deletePointer();
}
/**
* Resets the pointer with the new value. Old object will be destroyed
*/
void reset(PointerType o = 0) {
- delete _pointer;
+ deletePointer();
_pointer = o;
}
@@ -273,10 +275,19 @@ public:
return r;
}
-private:
+protected:
PointerType _pointer;
};
+template<typename T>
+class ScopedPtrC : public ScopedPtr<T> {
+public:
+ typedef T *PointerType;
+
+ explicit ScopedPtrC(PointerType o = 0) : ScopedPtr<T>(o) {}
+
+ void deletePointer() { free(ScopedPtr<T>::_pointer); }
+};
} // End of namespace Common