Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r61314 - sandbox/memory/boost/memory
From: xushiweizh_at_[hidden]
Date: 2010-04-16 06:59:10


Author: xushiwei
Date: 2010-04-16 06:59:08 EDT (Fri, 16 Apr 2010)
New Revision: 61314
URL: http://svn.boost.org/trac/boost/changeset/61314

Log:
class pools_alloc - support user-defined system alloc;
Text files modified:
   sandbox/memory/boost/memory/pools.hpp | 21 +++++++++++----------
   sandbox/memory/boost/memory/system_alloc.hpp | 6 +-----
   2 files changed, 12 insertions(+), 15 deletions(-)

Modified: sandbox/memory/boost/memory/pools.hpp
==============================================================================
--- sandbox/memory/boost/memory/pools.hpp (original)
+++ sandbox/memory/boost/memory/pools.hpp 2010-04-16 06:59:08 EDT (Fri, 16 Apr 2010)
@@ -82,13 +82,12 @@
 // -------------------------------------------------------------------------
 // class pools
 
-class pools
+template <class PolicyT>
+class pools_alloc
 {
 private:
- typedef NS_BOOST_MEMORY_POLICY::stdlib PolicyT;
-
- pools(const pools&);
- const pools& operator=(const pools&);
+ pools_alloc(const pools_alloc&);
+ const pools_alloc& operator=(const pools_alloc&);
 
 public:
         typedef size_t size_type;
@@ -120,7 +119,7 @@
         pool_type m_poolAlloc;
 
 public:
- pools()
+ pools_alloc()
                 : m_poolAlloc(sizeof(pool_type))
         {
                 memset(m_pools, 0, sizeof(pool_type*)*NPOOL);
@@ -128,7 +127,7 @@
                 const size_type index = (sizeof(pool_type) - 1) >> ALIGN_BITS1;
                 m_pools[index] = &m_poolAlloc;
         }
- ~pools()
+ ~pools_alloc()
         {
                 for (size_type i = 0; i < NPOOL; ++i)
                 {
@@ -193,7 +192,7 @@
         //
         size_t BOOST_MEMORY_CALL alloc_size(void* p, size_t cb)
         {
- typedef PolicyT::system_alloc_type sysalloc;
+ typedef typename PolicyT::system_alloc_type sysalloc;
                 
                 if (cb - 1 < (size_type)MAX_BYTES1)
                         return get_pool1(cb).alloc_size();
@@ -205,7 +204,7 @@
 
         void* BOOST_MEMORY_CALL allocate(size_t cb)
         {
- typedef PolicyT::system_alloc_type sysalloc;
+ typedef typename PolicyT::system_alloc_type sysalloc;
 
                 void* p;
                 
@@ -224,7 +223,7 @@
 
         void BOOST_MEMORY_CALL deallocate(void* p, size_t cb)
         {
- typedef PolicyT::system_alloc_type sysalloc;
+ typedef typename PolicyT::system_alloc_type sysalloc;
 
 #if defined(BOOST_MEMORY_DEBUG_POOLS)
                 printf("pools %p deallocate: %p (bytes: %u)\n", this, p, cb);
@@ -238,6 +237,8 @@
         }
 };
 
+typedef pools_alloc<stdlib> pools;
+
 // -------------------------------------------------------------------------
 
 NS_BOOST_MEMORY_END

Modified: sandbox/memory/boost/memory/system_alloc.hpp
==============================================================================
--- sandbox/memory/boost/memory/system_alloc.hpp (original)
+++ sandbox/memory/boost/memory/system_alloc.hpp 2010-04-16 06:59:08 EDT (Fri, 16 Apr 2010)
@@ -85,11 +85,7 @@
         typedef system_alloc system_alloc_type;
 };
 
-class stdlib : public sys
-{
-public:
- typedef stdlib_alloc alloc_type;
-};
+typedef sys stdlib;
 
 NS_BOOST_MEMORY_POLICY_END
 


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