|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r63688 - sandbox/memory/boost/memory
From: xushiweizh_at_[hidden]
Date: 2010-07-06 07:37:15
Author: xushiwei
Date: 2010-07-06 07:37:14 EDT (Tue, 06 Jul 2010)
New Revision: 63688
URL: http://svn.boost.org/trac/boost/changeset/63688
Log:
bug fix: deallocate huge block allocated by block_alloc class;
Text files modified:
sandbox/memory/boost/memory/block_pool.hpp | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)
Modified: sandbox/memory/boost/memory/block_pool.hpp
==============================================================================
--- sandbox/memory/boost/memory/block_pool.hpp (original)
+++ sandbox/memory/boost/memory/block_pool.hpp 2010-07-06 07:37:14 EDT (Tue, 06 Jul 2010)
@@ -77,6 +77,7 @@
int m_nFree;
const int m_nFreeLimit;
+ size_t m_cbAllocSize;
private:
block_alloc(const block_alloc&);
@@ -84,9 +85,11 @@
public:
block_alloc(int cbFreeLimit = INT_MAX)
- : m_freeList(NULL), m_nFree(0),
- m_nFreeLimit(cbFreeLimit / m_cbBlock)
+ : m_nFree(1), m_nFreeLimit(cbFreeLimit / m_cbBlock)
{
+ m_freeList = (Block*)AllocT::allocate(m_cbBlock);
+ m_freeList->next = NULL;
+ m_cbAllocSize = AllocT::alloc_size(m_freeList);
}
~block_alloc()
{
@@ -120,7 +123,7 @@
void BOOST_MEMORY_CALL deallocate(void* p)
{
- if (m_nFree >= m_nFreeLimit) {
+ if (AllocT::alloc_size(p) > m_cbAllocSize || m_nFree >= m_nFreeLimit) {
AllocT::deallocate(p);
}
else {
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