From 02f3bfdbf416ad86de9d3a0b9246733b975338ee Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 31 Jul 2003 21:44:35 +0000 Subject: [PATCH] SwigValueWrapper fixes - memory leak fix - default arguments for parameters that are classes bug fix git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@4971 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- SWIG/Lib/swig.swg | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/SWIG/Lib/swig.swg b/SWIG/Lib/swig.swg index 9e1fe888f..10221e2b9 100644 --- a/SWIG/Lib/swig.swg +++ b/SWIG/Lib/swig.swg @@ -311,12 +311,15 @@ namespace std { template class SwigValueWrapper { T *tt; public: - inline SwigValueWrapper() : tt(0) { } - inline SwigValueWrapper(const T& t) : tt(new T(t)) { } - inline ~SwigValueWrapper() { if (tt) delete tt; } - inline SwigValueWrapper& operator=(const T& t) { tt = new T(t); return *this; } - inline operator T&() const { return *tt; } - inline T *operator&() { return tt; } + SwigValueWrapper() : tt(0) { } + SwigValueWrapper(const SwigValueWrapper& rhs) : tt(new T(*rhs.tt)) { } + SwigValueWrapper(const T& t) : tt(new T(t)) { } + ~SwigValueWrapper() { delete tt; } + SwigValueWrapper& operator=(const T& t) { delete tt; tt = new T(t); return *this; } + operator T&() const { return *tt; } + T *operator&() { return tt; } +private: + SwigValueWrapper& operator=(const SwigValueWrapper& rhs); }; #endif %}