Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r53184 - sandbox/memory/boost/memory
From: xushiweizh_at_[hidden]
Date: 2009-05-22 14:47:16


Author: xushiwei
Date: 2009-05-22 14:47:14 EDT (Fri, 22 May 2009)
New Revision: 53184
URL: http://svn.boost.org/trac/boost/changeset/53184

Log:
1. BOOST_MEMORY_DBG_FILL
2. object_pool::destroy bug-fix: memory leak
Text files modified:
   sandbox/memory/boost/memory/fixed_alloc.hpp | 11 +++++++++++
   sandbox/memory/boost/memory/object_pool.hpp | 1 +
   2 files changed, 12 insertions(+), 0 deletions(-)

Modified: sandbox/memory/boost/memory/fixed_alloc.hpp
==============================================================================
--- sandbox/memory/boost/memory/fixed_alloc.hpp (original)
+++ sandbox/memory/boost/memory/fixed_alloc.hpp 2009-05-22 14:47:14 EDT (Fri, 22 May 2009)
@@ -36,6 +36,14 @@
 #define MIN(x, y) ((x) < (y) ? (x) : (y))
 #endif
 
+#ifndef BOOST_MEMORY_DBG_FILL
+#if defined(_DEBUG)
+#define BOOST_MEMORY_DBG_FILL(p, cb) memset(p, 0xcd, cb)
+#else
+#define BOOST_MEMORY_DBG_FILL(p, cb)
+#endif
+#endif
+
 template <class PolicyT>
 class fixed_alloc
 {
@@ -187,6 +195,8 @@
                 void* p = &m_freelist.front();
                 ++chunkHeader_(p)->nUsed;
                 m_freelist.pop_front();
+
+ BOOST_MEMORY_DBG_FILL(p, element_size());
                 return p;
         }
 
@@ -195,6 +205,7 @@
                 MemBlock* const blk = chunkHeader_(p);
 
                 BOOST_MEMORY_ASSERT(blk->nUsed > 0 && blk->nUsed <= m_nMaxPerBlock);
+ BOOST_MEMORY_DBG_FILL(p, element_size());
 
                 m_freelist.push_front((FreeChunk*)p);
                 if (--blk->nUsed == 0 && blk != m_lastBlock)

Modified: sandbox/memory/boost/memory/object_pool.hpp
==============================================================================
--- sandbox/memory/boost/memory/object_pool.hpp (original)
+++ sandbox/memory/boost/memory/object_pool.hpp 2009-05-22 14:47:14 EDT (Fri, 22 May 2009)
@@ -194,6 +194,7 @@
         }
 
         __forceinline void BOOST_MEMORY_CALL destroy(Type* obj) {
+ PoolT::deallocate(obj);
         }
 };
 


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