Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r78339 - sandbox/pool/boost/pool
From: svart.riddare_at_[hidden]
Date: 2012-05-05 16:34:31


Author: edupuis
Date: 2012-05-05 16:34:30 EDT (Sat, 05 May 2012)
New Revision: 78339
URL: http://svn.boost.org/trac/boost/changeset/78339

Log:
Removed #ifdef BOOST_POOL_VALGRIND sections.
Text files modified:
   sandbox/pool/boost/pool/object_pool.hpp | 9 --
   sandbox/pool/boost/pool/pool.hpp | 129 ----------------------------------------
   2 files changed, 0 insertions(+), 138 deletions(-)

Modified: sandbox/pool/boost/pool/object_pool.hpp
==============================================================================
--- sandbox/pool/boost/pool/object_pool.hpp (original)
+++ sandbox/pool/boost/pool/object_pool.hpp 2012-05-05 16:34:30 EDT (Sat, 05 May 2012)
@@ -201,7 +201,6 @@
 template <typename T, typename Pool>
 object_pool_base<T, Pool>::~object_pool_base()
 {
-#ifndef BOOST_POOL_VALGRIND
   // handle trivial case of invalid list.
   if (!this->list.valid())
     return;
@@ -249,14 +248,6 @@
   // Make the block list empty so that the inherited destructor doesn't try to
   // free it again.
   this->list.invalidate();
-#else
- // destruct all used elements:
- for(std::set<void*>::iterator pos = this->used_list.begin(); pos != this->used_list.end(); ++pos)
- {
- static_cast<T*>(*pos)->~T();
- }
- // base class will actually free the memory...
-#endif
 }
 
 /*! \brief A template class

Modified: sandbox/pool/boost/pool/pool.hpp
==============================================================================
--- sandbox/pool/boost/pool/pool.hpp (original)
+++ sandbox/pool/boost/pool/pool.hpp 2012-05-05 16:34:30 EDT (Sat, 05 May 2012)
@@ -43,10 +43,6 @@
 #include <iostream>
 #include<iomanip>
 #endif
-#ifdef BOOST_POOL_VALGRIND
-#include <set>
-#include <valgrind/memcheck.h>
-#endif
 
 #ifdef BOOST_NO_STDC_NAMESPACE
  namespace std { using ::malloc; using ::free; }
@@ -241,7 +237,6 @@
 }; // class PODptr
 } // namespace details
 
-#ifndef BOOST_POOL_VALGRIND
 /*!
   \brief A fast memory allocator that guarantees proper alignment of all allocated chunks.
 
@@ -900,130 +895,6 @@
   return iter;
 }
 
-#else // BOOST_POOL_VALGRIND
-
-template<typename UserAllocator>
-class pool
-{
-public:
- // types
- typedef UserAllocator user_allocator; // User allocator.
- typedef typename UserAllocator::size_type size_type; // An unsigned integral type that can represent the size of the largest object to be allocated.
- typedef typename UserAllocator::difference_type difference_type; // A signed integral type that can represent the difference of any two pointers.
-
- // construct/copy/destruct
- explicit pool(const size_type s, const size_type = 32, const size_type m = 0) : chunk_size(s), max_alloc_size(m) {}
- ~pool()
- {
- purge_memory();
- }
-
- bool release_memory()
- {
- bool ret = free_list.empty() ? false : true;
- for(std::set<void*>::iterator pos = free_list.begin(); pos != free_list.end(); ++pos)
- {
- (user_allocator::free)(static_cast<char*>(*pos));
- }
- free_list.clear();
- return ret;
- }
- bool purge_memory()
- {
- bool ret = free_list.empty() && used_list.empty() ? false : true;
- for(std::set<void*>::iterator pos = free_list.begin(); pos != free_list.end(); ++pos)
- {
- (user_allocator::free)(static_cast<char*>(*pos));
- }
- free_list.clear();
- for(std::set<void*>::iterator pos = used_list.begin(); pos != used_list.end(); ++pos)
- {
- (user_allocator::free)(static_cast<char*>(*pos));
- }
- used_list.clear();
- return ret;
- }
- size_type get_next_size() const
- {
- return 1;
- }
- void set_next_size(const size_type){}
- size_type get_max_size() const
- {
- return max_alloc_size;
- }
- void set_max_size(const size_type s)
- {
- max_alloc_size = s;
- }
- size_type get_requested_size() const
- {
- return chunk_size;
- }
- void * malloc BOOST_PREVENT_MACRO_SUBSTITUTION()
- {
- void* ret;
- if(free_list.empty())
- {
- ret = (user_allocator::malloc)(chunk_size);
- VALGRIND_MAKE_MEM_UNDEFINED(ret, chunk_size);
- }
- else
- {
- ret = *free_list.begin();
- free_list.erase(free_list.begin());
- VALGRIND_MAKE_MEM_UNDEFINED(ret, chunk_size);
- }
- used_list.insert(ret);
- return ret;
- }
- void * ordered_malloc()
- {
- return (this->malloc)();
- }
- void * ordered_malloc(size_type n)
- {
- if(max_alloc_size && (n > max_alloc_size))
- return 0;
- void* ret = (user_allocator::malloc)(chunk_size * n);
- used_list.insert(ret);
- return ret;
- }
- void free BOOST_PREVENT_MACRO_SUBSTITUTION(void *const chunk)
- {
- BOOST_ASSERT(used_list.count(chunk) == 1);
- BOOST_ASSERT(free_list.count(chunk) == 0);
- used_list.erase(chunk);
- free_list.insert(chunk);
- VALGRIND_MAKE_MEM_NOACCESS(chunk, chunk_size);
- }
- void ordered_free(void *const chunk)
- {
- return (this->free)(chunk);
- }
- void free BOOST_PREVENT_MACRO_SUBSTITUTION(void *const chunk, const size_type)
- {
- BOOST_ASSERT(used_list.count(chunk) == 1);
- BOOST_ASSERT(free_list.count(chunk) == 0);
- used_list.erase(chunk);
- (user_allocator::free)(static_cast<char*>(chunk));
- }
- void ordered_free(void *const chunk, const size_type n)
- {
- (this->free)(chunk, n);
- }
- bool is_from(void *const chunk) const
- {
- return used_list.count(chunk) || free_list.count(chunk);
- }
-
-protected:
- size_type chunk_size, max_alloc_size;
- std::set<void*> free_list, used_list;
-};
-
-#endif
-
 } // namespace boost
 
 #ifdef BOOST_MSVC


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