Chris@102: ////////////////////////////////////////////////////////////////////////////// Chris@102: // Chris@102: // (C) Copyright Ion Gaztanaga 2005-2013. Distributed under the Boost Chris@102: // Software License, Version 1.0. (See accompanying file Chris@102: // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) Chris@102: // Chris@102: // See http://www.boost.org/libs/container for documentation. Chris@102: // Chris@102: ////////////////////////////////////////////////////////////////////////////// Chris@102: Chris@102: #ifndef BOOST_CONTAINER_DETAIL_POOL_COMMON_ALLOC_HPP Chris@102: #define BOOST_CONTAINER_DETAIL_POOL_COMMON_ALLOC_HPP Chris@102: Chris@102: #ifndef BOOST_CONFIG_HPP Chris@102: # include Chris@102: #endif Chris@102: Chris@102: #if defined(BOOST_HAS_PRAGMA_ONCE) Chris@102: # pragma once Chris@102: #endif Chris@102: Chris@102: #include Chris@102: #include Chris@102: #include Chris@102: Chris@102: #include Chris@102: #include Chris@102: #include Chris@102: #include Chris@102: Chris@102: namespace boost{ Chris@102: namespace container{ Chris@102: namespace container_detail{ Chris@102: Chris@102: struct node_slist_helper Chris@102: : public boost::container::container_detail::node_slist Chris@102: {}; Chris@102: Chris@102: struct fake_segment_manager Chris@102: { Chris@102: typedef void * void_pointer; Chris@102: static const std::size_t PayloadPerAllocation = BOOST_CONTAINER_ALLOCATION_PAYLOAD; Chris@102: Chris@102: typedef boost::container::container_detail:: Chris@102: basic_multiallocation_chain multiallocation_chain; Chris@102: static void deallocate(void_pointer p) Chris@102: { boost_cont_free(p); } Chris@102: Chris@102: static void deallocate_many(multiallocation_chain &chain) Chris@102: { Chris@102: std::size_t size = chain.size(); Chris@102: std::pair ptrs = chain.extract_data(); Chris@102: boost_cont_memchain dlchain; Chris@102: BOOST_CONTAINER_MEMCHAIN_INIT_FROM(&dlchain, ptrs.first, ptrs.second, size); Chris@102: boost_cont_multidealloc(&dlchain); Chris@102: } Chris@102: Chris@102: typedef std::ptrdiff_t difference_type; Chris@102: typedef std::size_t size_type; Chris@102: Chris@102: static void *allocate_aligned(std::size_t nbytes, std::size_t alignment) Chris@102: { Chris@102: void *ret = boost_cont_memalign(nbytes, alignment); Chris@102: if(!ret) Chris@102: boost::container::throw_bad_alloc(); Chris@102: return ret; Chris@102: } Chris@102: Chris@102: static void *allocate(std::size_t nbytes) Chris@102: { Chris@102: void *ret = boost_cont_malloc(nbytes); Chris@102: if(!ret) Chris@102: boost::container::throw_bad_alloc(); Chris@102: return ret; Chris@102: } Chris@102: }; Chris@102: Chris@102: } //namespace boost{ Chris@102: } //namespace container{ Chris@102: } //namespace container_detail{ Chris@102: Chris@102: namespace boost { Chris@102: namespace container { Chris@102: namespace container_detail { Chris@102: Chris@102: template Chris@102: struct is_stateless_segment_manager; Chris@102: Chris@102: template<> Chris@102: struct is_stateless_segment_manager Chris@102: Chris@102: { Chris@102: static const bool value = true; Chris@102: }; Chris@102: Chris@102: } //namespace container_detail { Chris@102: } //namespace container { Chris@102: } //namespace boost { Chris@102: Chris@102: #include Chris@102: Chris@102: #endif //BOOST_CONTAINER_DETAIL_POOL_COMMON_ALLOC_HPP