From: vsr Date: Thu, 12 Nov 2015 16:30:30 +0000 (+0300) Subject: gcc 4.9 compatibility: v2 (avoid memory leaks) X-Git-Tag: V_2.1.0~243^2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=aee7dc0db829bf9b77cd7ef20f6c03e9d0f8c4a2;p=modules%2Fshaper.git gcc 4.9 compatibility: v2 (avoid memory leaks) --- diff --git a/src/GeomAPI/GeomAPI_Interface.h b/src/GeomAPI/GeomAPI_Interface.h index de51617ae..27b822012 100644 --- a/src/GeomAPI/GeomAPI_Interface.h +++ b/src/GeomAPI/GeomAPI_Interface.h @@ -16,6 +16,11 @@ * \brief General base class for all interfaces in this package */ +template +void GeomAPI_deleter( void* p ) { + delete reinterpret_cast(p); +} + class GeomAPI_Interface { private: @@ -28,7 +33,7 @@ class GeomAPI_Interface /// Constructor by the impl pointer (used for internal needs) template explicit GeomAPI_Interface(T* theImpl) { - myImpl.reset(reinterpret_cast(theImpl)); + myImpl = std::shared_ptr(reinterpret_cast(theImpl), GeomAPI_deleter); } /// Destructor @@ -52,7 +57,7 @@ class GeomAPI_Interface /// Updates the impl (deletes the old one) template inline void setImpl(T* theImpl) { - myImpl.reset(reinterpret_cast(theImpl)); + myImpl = std::shared_ptr(reinterpret_cast(theImpl), GeomAPI_deleter); } /// Returns true if the impl is empty