|
Boost-Commit : |
From: xushiweizh_at_[hidden]
Date: 2008-04-29 02:12:23
Author: xushiwei
Date: 2008-04-29 02:12:22 EDT (Tue, 29 Apr 2008)
New Revision: 44874
URL: http://svn.boost.org/trac/boost/changeset/44874
Log:
1. gc_alloc_imp => region_alloc
2. block_pool_imp::alloc_size, proxy_alloc::alloc_size
Text files modified:
sandbox/memory/boost/memory/auto_alloc.hpp | 24 +++++++++++++-----------
sandbox/memory/boost/memory/scoped_alloc.hpp | 10 ++++++++--
2 files changed, 21 insertions(+), 13 deletions(-)
Modified: sandbox/memory/boost/memory/auto_alloc.hpp
==============================================================================
--- sandbox/memory/boost/memory/auto_alloc.hpp (original)
+++ sandbox/memory/boost/memory/auto_alloc.hpp 2008-04-29 02:12:22 EDT (Tue, 29 Apr 2008)
@@ -19,10 +19,10 @@
__NS_BOOST_BEGIN
// -------------------------------------------------------------------------
-// class gc_alloc_imp
+// class region_alloc
template <class _Policy>
-class gc_alloc_imp
+class region_alloc
{
private:
typedef typename _Policy::allocator_type _Alloc;
@@ -31,10 +31,11 @@
enum { MemBlockSize = _Policy::MemBlockSize };
enum { HeaderSize = sizeof(void*) };
enum { BlockSize = MemBlockSize - HeaderSize };
- enum { IsAutoFreeAllocator = 1 };
+ enum { IsGCAllocator = TRUE };
typedef _Alloc allocator_type;
+#pragma pack(1)
private:
struct _MemBlock
{
@@ -46,6 +47,7 @@
_DestroyNode* pPrev;
destructor_t fnDestroy;
};
+#pragma pack()
char* m_begin;
char* m_end;
@@ -53,7 +55,7 @@
_Alloc m_alloc;
private:
- const gc_alloc_imp& operator=(const gc_alloc_imp&);
+ const region_alloc& operator=(const region_alloc&);
_MemBlock* BOOST_MEMORY_CALL _ChainHeader() const
{
@@ -61,26 +63,26 @@
}
public:
- gc_alloc_imp() : m_destroyChain(NULL)
+ region_alloc() : m_destroyChain(NULL)
{
m_begin = m_end = (char*)HeaderSize;
}
- explicit gc_alloc_imp(_Alloc alloc) : m_alloc(alloc), m_destroyChain(NULL)
+ explicit region_alloc(_Alloc alloc) : m_alloc(alloc), m_destroyChain(NULL)
{
m_begin = m_end = (char*)HeaderSize;
}
- explicit gc_alloc_imp(gc_alloc_imp& owner)
+ explicit region_alloc(region_alloc& owner)
: m_alloc(owner.m_alloc), m_destroyChain(NULL)
{
m_begin = m_end = (char*)HeaderSize;
}
- ~gc_alloc_imp()
+ ~region_alloc()
{
clear();
}
- void BOOST_MEMORY_CALL swap(gc_alloc_imp& o)
+ void BOOST_MEMORY_CALL swap(region_alloc& o)
{
std::swap(m_begin, o.m_begin);
std::swap(m_end, o.m_end);
@@ -150,7 +152,7 @@
_MemBlock* pNew = (_MemBlock*)m_alloc.allocate(sizeof(_MemBlock));
pNew->pPrev = _ChainHeader();
m_begin = pNew->buffer;
- m_end = m_begin + BlockSize;
+ m_end = (char*)pNew + m_alloc.alloc_size(pNew);
}
}
return m_end -= cb;
@@ -197,7 +199,7 @@
typedef system_alloc allocator_type;
};
-typedef gc_alloc_imp<_sys_alloc> auto_alloc;
+typedef region_alloc<_sys_alloc> auto_alloc;
// -------------------------------------------------------------------------
// $Log: auto_alloc.hpp,v $
Modified: sandbox/memory/boost/memory/scoped_alloc.hpp
==============================================================================
--- sandbox/memory/boost/memory/scoped_alloc.hpp (original)
+++ sandbox/memory/boost/memory/scoped_alloc.hpp 2008-04-29 02:12:22 EDT (Tue, 29 Apr 2008)
@@ -45,8 +45,9 @@
public:
void* BOOST_MEMORY_CALL allocate(size_t cb) { return m_alloc->allocate(cb); }
- void BOOST_MEMORY_CALL deallocate(void* p) { m_alloc->deallocate(p); }
+ void BOOST_MEMORY_CALL deallocate(void* p) { m_alloc->deallocate(p); }
void BOOST_MEMORY_CALL swap(proxy_alloc& o) { std::swap(m_alloc, o.m_alloc); }
+ size_t BOOST_MEMORY_CALL alloc_size(void* p) const { return m_alloc->alloc_size(p); }
};
// -------------------------------------------------------------------------
@@ -116,6 +117,11 @@
}
}
+ static size_t BOOST_MEMORY_CALL alloc_size(void* p)
+ {
+ return _Alloc::alloc_size(p);
+ }
+
void BOOST_MEMORY_CALL clear()
{
while (m_freeList)
@@ -174,7 +180,7 @@
typedef proxy_block_pool allocator_type;
};
-typedef gc_alloc_imp<_pool_alloc> scoped_alloc;
+typedef region_alloc<_pool_alloc> scoped_alloc;
// -------------------------------------------------------------------------
// $Log: $
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