Boost logo

Boost-Commit :

From: jmcintyre_at_[hidden]
Date: 2008-04-28 17:03:27


Author: jared
Date: 2008-04-28 17:03:27 EDT (Mon, 28 Apr 2008)
New Revision: 44860
URL: http://svn.boost.org/trac/boost/changeset/44860

Log:
Fix memory leak.
Text files modified:
   sandbox/pinhole/boost/pinhole/property_manager.hpp | 17 +++++++++++++----
   sandbox/pinhole/libs/pinhole/src/globals.cpp | 4 ++--
   2 files changed, 15 insertions(+), 6 deletions(-)

Modified: sandbox/pinhole/boost/pinhole/property_manager.hpp
==============================================================================
--- sandbox/pinhole/boost/pinhole/property_manager.hpp (original)
+++ sandbox/pinhole/boost/pinhole/property_manager.hpp 2008-04-28 17:03:27 EDT (Mon, 28 Apr 2008)
@@ -36,12 +36,12 @@
     public :
         static event_source* instance()
         {
- if ( m_instance == 0 ) // is it the first call?
+ if ( !m_instance ) // is it the first call?
             {
- m_instance = new event_source; // create sole instance
+ m_instance.reset( new event_source ); // create sole instance
             }
             
- return m_instance; // address of sole instance
+ return m_instance.get(); // address of sole instance
         }
         
         #if defined(BOOST_MSVC)
@@ -64,7 +64,16 @@
         }
         
     private :
- static event_source *m_instance;
+
+ #if defined(BOOST_MSVC)
+ #pragma warning(push)
+ #pragma warning( disable: 4251 )
+ #endif
+ static boost::shared_ptr<event_source> m_instance;
+ #if defined(BOOST_MSVC)
+ #pragma warning(pop)
+ #endif
+
         event_source(){};
         
     };

Modified: sandbox/pinhole/libs/pinhole/src/globals.cpp
==============================================================================
--- sandbox/pinhole/libs/pinhole/src/globals.cpp (original)
+++ sandbox/pinhole/libs/pinhole/src/globals.cpp 2008-04-28 17:03:27 EDT (Mon, 28 Apr 2008)
@@ -12,5 +12,5 @@
 boost::shared_ptr<boost::pinhole::property_manager>
     boost::pinhole::property_manager::m_instance(new boost::pinhole::property_manager);
 
-boost::pinhole::event_source
- *boost::pinhole::event_source::m_instance = 0;
\ No newline at end of file
+boost::shared_ptr<boost::pinhole::event_source>
+ boost::pinhole::event_source::m_instance;
\ No newline at end of file


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk