From c2cafe426e8216d46a70b479ff0071a8b66b9327 Mon Sep 17 00:00:00 2001 From: Yotam Barnoy Date: Mon, 6 Sep 2010 13:31:27 +0000 Subject: PLUGINS: used variation of ScopedPtr to clean up load() function svn-id: r52592 --- common/ptr.h | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'common') diff --git a/common/ptr.h b/common/ptr.h index 7307038936..524879652c 100644 --- a/common/ptr.h +++ b/common/ptr.h @@ -235,6 +235,7 @@ public: ReferenceType operator*() const { return *_pointer; } PointerType operator->() const { return _pointer; } operator PointerType() const { return _pointer; } + /** * Implicit conversion operator to bool for convenience, to make @@ -242,15 +243,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 +276,19 @@ public: return r; } -private: - PointerType _pointer; +protected: + PointerType _pointer; }; +template +class ScopedPtrC : public ScopedPtr { +public: + typedef T *PointerType; + + explicit ScopedPtrC(PointerType o = 0) : ScopedPtr(o) {} + + void deletePointer() { free(ScopedPtr::_pointer); } +}; } // End of namespace Common -- cgit v1.2.3