Add Polymorphic Memory Resource utilities and rework the separately compiled library:

- Dlmalloc's based C function are boost_cont_xxx no longer exported, but wrapped into C++ linkage dlmalloc_xxx functions to effectively reuse Boost's dynamic library and autolink machinery instead of rewriting machinery to compile the C source file.
- Refactored scoped_allocator_adaptor's construct logic as it was shared with polymorphic allocator's one. Moved common logic to detail/dispatch_uses_allocator.hpp. Refactored also scoped_allocator_adaptor test utilities to be reused with polymorphic_allocator tests.
This commit is contained in:
Ion Gaztañaga committed 2015-09-07 19:16:46 +02:00
1 parent 77100c0bfc
commit 33d2f0f7af
110 files changed
+10143 -1160

No files matched your search

@@ -25,7 +25,7 @@
#include <boost/intrusive/slist.hpp>
#include <boost/container/detail/pool_common.hpp>
#include <boost/container/detail/alloc_lib.h>
#include <boost/container/detail/dlmalloc.hpp>
#include <cstddef>
namespace boost{
@@ -44,15 +44,15 @@ struct fake_segment_manager
typedef boost::container::container_detail::
basic_multiallocation_chain<void*> multiallocation_chain;
static void deallocate(void_pointer p)
{ boost_cont_free(p); }
{ dlmalloc_free(p); }
static void deallocate_many(multiallocation_chain &chain)
{
std::size_t size = chain.size();
std::pair<void*, void*> ptrs = chain.extract_data();
boost_cont_memchain dlchain;
dlmalloc_memchain dlchain;
BOOST_CONTAINER_MEMCHAIN_INIT_FROM(&dlchain, ptrs.first, ptrs.second, size);
boost_cont_multidealloc(&dlchain);
dlmalloc_multidealloc(&dlchain);
}
typedef std::ptrdiff_t difference_type;
@@ -60,7 +60,7 @@ struct fake_segment_manager
static void *allocate_aligned(std::size_t nbytes, std::size_t alignment)
{
void *ret = boost_cont_memalign(nbytes, alignment);
void *ret = dlmalloc_memalign(nbytes, alignment);
if(!ret)
boost::container::throw_bad_alloc();
return ret;
@@ -68,7 +68,7 @@ struct fake_segment_manager
static void *allocate(std::size_t nbytes)
{
void *ret = boost_cont_malloc(nbytes);
void *ret = dlmalloc_malloc(nbytes);
if(!ret)
boost::container::throw_bad_alloc();
return ret;