From b8fd08aaf0e0dd9bcacdfc4169842303d236821f Mon Sep 17 00:00:00 2001 From: Jan Christoph Uhde Date: Sat, 26 Jun 2021 17:36:31 +0200 Subject: [PATCH] add documentation --- README.md | 155 ++++++++++++++++++ README.rst | 2 - .../ext/allocators/alignment_segregator.hpp | 46 +----- include/ext/allocators/bitmap.hpp | 12 +- include/ext/allocators/blob.hpp | 27 +-- include/ext/allocators/cascading.hpp | 58 +------ include/ext/allocators/detail_traits.hpp | 25 --- include/ext/allocators/fallback.hpp | 36 +--- .../{detail_block.hpp => memory_block.hpp} | 13 +- include/ext/allocators/null.hpp | 6 +- include/ext/allocators/singleton.hpp | 32 +--- include/ext/allocators/size_segregator.hpp | 42 +---- include/ext/allocators/stack.hpp | 32 ++-- include/ext/allocators/standard.hpp | 3 +- include/ext/allocators/stl_wrapper.hpp | 3 +- tests/test_blob_allocator.cpp | 2 + tests/test_memblock.cpp | 4 +- 17 files changed, 241 insertions(+), 257 deletions(-) create mode 100644 README.md delete mode 100644 README.rst delete mode 100644 include/ext/allocators/detail_traits.hpp rename include/ext/allocators/{detail_block.hpp => memory_block.hpp} (84%) diff --git a/README.md b/README.md new file mode 100644 index 0000000..1882f49 --- /dev/null +++ b/README.md @@ -0,0 +1,155 @@ +# Simple Allocation Lib + +## Basics + +### Memory Blocks + +A `memory_block` describes any allocation made by any of the allocators. It consists of an +`address` and `size`. + +### STL Wrapper + +`stl_wrapper.hpp` provides means to make use of the allocators with container types from +standard template library. + +## Common Allocator Functions + +### Modifiers + +```c++ + memory_block allocate(std::size_t alignment, std::size_t size) noexcept +``` + +Allocates memory of `size` and `alignment`. + + +```c++ + void deallocate(memory_block block) EXTALLOC_NOEXCEPT +``` + +Deallocates given `block`. + +### Observers + +```c++ + bool owns(memory_block block) EXTALLOC_NOEXCEPT +``` + +Returns true if `block` is owned by allocator, false otherwise. + + +```c++ + static constexpr std::size_t actual_size(std::size_t alignment, std::size_t size) noexcept +``` + +Returns the actual allocated size the allocator would allocate when `allocate` +is called with `size` and `alignment`. + + +## Not Always Implemented +TODO - check where this is meaningful + +```c++ + memory_block allocate_all(std::size_t alignment) noexcept +``` + +Allocates as much memory of `alignment` as the allocator can provide. + +```c++ + void deallocate_all() noexcept +``` + +Deallocates all memory owned by this allocator. + +```c++ + template std::tuple + allocate_array(std::size_t alignment, std::size_t size, std::size_t count, OutItr out_itr) +``` + +Allocates multiple `memory_blocks` instead of a single block. +TODO - check if always continous and update wording or change function name + +## List of Allocators + +### Providing Allocators + +Allocators in this group provide access to system's memory. They allocate with +`malloc`, by creating an object on the stack or even by using other allocation +libs. + +#### Standard + +This allocator uses `std::aligned_alloc` and `free` to provide memory. + +Note: The standard allocator always claims to own any `memory_block`. Make sure to have asked all +other involved allocators before you deallocate using this allocator. + +#### Blob + +This allocator allocates a blob of memory in itself. So depending where it is +created it can provide memory on the stack or heap. + +#### Null + +This allocator always fails to allocate. + +### Managing Allocators + +Allocators in this group provide allocations strategies and manage +how the underlying pools are accessed. + +#### Alignment Segregator + +This allocator dispatches allocation requests to underlying allocators. When the +requested alignment is less or equal the `dividing_alignment`, then it will use +the `FirstAllocator` otherwise the `SecondAllocator`. + +#### Size Segregator + +This allocator dispatches allocation requests to underlying allocators. When the +requested size is less or equal the `dividing_size`. Then it will use the +`FirstAllocator` otherwise the `SecondAllocator`. + +#### Fallback + +This allocator dispatches allocation requests to the `FirstAllocator` as long +as it is able to provide valid `memory_blocks`. If the `FirstAllocator` is +exhausted it falls back to the `SecondAllocator`. + +#### Stack (dumb - and therefor mostly short lived) + +This allocator allocates and deallocates memory in a stack-like fashion. It is +meant to be used in small scopes, when memory is mostly just allocated and +freed at scope exit. This is because tracking the allocation order is often +infeasible in bigger scopes and the allocator needs to deallocate blocks in +an exact order for deallocation to work properly. + +#### Bitmap + +This allocator encodes in single bits which regions are allocated and which are not. +Therefore it is easy for this allocator to provide single allocations. + +Note: Supports array allocation + + +### Special Allocators + +#### Singleton +TODO + +Is a singleton (global) allocator with `thread_local` memory really that useful? + +### WIP Allocators + +#### Cascading (WIP) + +TODO + +Has list of children and get memory from parent to create new children. +(how to keep tack of children that get empty) + +#### Freelist (WIP) + +TODO + +liked list ... unallocated regions point to next unallocated regions ... diff --git a/README.rst b/README.rst deleted file mode 100644 index 95bb3ee..0000000 --- a/README.rst +++ /dev/null @@ -1,2 +0,0 @@ -WIP -=== diff --git a/include/ext/allocators/alignment_segregator.hpp b/include/ext/allocators/alignment_segregator.hpp index d9e9593..468439f 100644 --- a/include/ext/allocators/alignment_segregator.hpp +++ b/include/ext/allocators/alignment_segregator.hpp @@ -1,51 +1,18 @@ #ifndef EXT_ALLOCATORS_ALIGNMENT_SEGREGATOR_HEADER #define EXT_ALLOCATORS_ALIGNMENT_SEGREGATOR_HEADER -#include "detail_block.hpp" -#include "detail_traits.hpp" +#include "memory_block.hpp" #include namespace EXT_ALLOCATOR_NAMESPACE { -namespace _detail { -template -struct extension_allocate_array {}; - -template -struct extension_allocate_array< - Derived, - FirstAllocator, - SecondAllocator, - AlignmentLessOrEqual, - std::enable_if_t<_detail::has_allocate_array_v && _detail::has_allocate_array_v>> { - template - std::tuple - allocate_array(std::size_t alignment, std::size_t size, std::size_t count, OutItr out_itr) { - auto* parent = static_cast(this); - if (alignment <= AlignmentLessOrEqual) { - return static_cast(parent)->allocate_array(alignment, size, count, out_itr); - } else { - return static_cast(parent)->allocate_array(alignment, size, count, out_itr); - } - } -}; -} // namespace _detail template struct alignment_segregator - : public _detail::extension_allocate_array< - alignment_segregator, - FirstAllocator, - SecondAllocator, - AlignmentLessOrEqual> - , private FirstAllocator - , private SecondAllocator { - - // using first_allocator = FirstAllocator; - // using second_allocator = SecondAllocator; + : private FirstAllocator + , private SecondAllocator +{ + using first_allocator = FirstAllocator; + using second_allocator = SecondAllocator; static constexpr std::size_t dividing_alignment = AlignmentLessOrEqual; static constexpr std::size_t actual_size(std::size_t alignment, std::size_t size) { @@ -76,6 +43,7 @@ struct alignment_segregator } } }; + } // namespace EXT_ALLOCATOR_NAMESPACE #endif // EXT_ALLOCATORS_ALIGNMENT_SEGREGATOR_HEADER diff --git a/include/ext/allocators/bitmap.hpp b/include/ext/allocators/bitmap.hpp index 3b4bf8d..bb39e76 100644 --- a/include/ext/allocators/bitmap.hpp +++ b/include/ext/allocators/bitmap.hpp @@ -1,7 +1,7 @@ #ifndef EXT_ALLOCATORS_BITMAP_HEADER #define EXT_ALLOCATORS_BITMAP_HEADER -#include "detail_block.hpp" +#include "memory_block.hpp" #include #include @@ -13,8 +13,7 @@ namespace EXT_ALLOCATOR_NAMESPACE { template class bitmap_allocator : ParentAllocator { - - public: +public: static_assert(NumChunks > 0, "NumChunks must be greater than 0"); static constexpr std::size_t bits = sizeof(uintptr_t) * 8; @@ -74,7 +73,7 @@ class bitmap_allocator : ParentAllocator { template std::tuple - allocate_array(std::size_t alignment, std::size_t size, std::size_t count, OutItr out_itr) { + allocate_array(std::size_t alignment, std::size_t size, std::size_t count, OutItr out_itr) { if (!_block.data) { init(); } @@ -113,7 +112,7 @@ class bitmap_allocator : ParentAllocator { } - private: +private: void init() { // get memory from the parent allocator _block = ParentAllocator::allocate(memory_alignment, chunk_size * num_chunks); @@ -163,9 +162,10 @@ class bitmap_allocator : ParentAllocator { return chunk_index >> 6; } - private: +private: memory_block _block; // internal allocation made by ParentAllocator std::array _free_blocks; + }; } // namespace EXT_ALLOCATOR_NAMESPACE diff --git a/include/ext/allocators/blob.hpp b/include/ext/allocators/blob.hpp index ffb143c..542a510 100644 --- a/include/ext/allocators/blob.hpp +++ b/include/ext/allocators/blob.hpp @@ -1,15 +1,16 @@ #ifndef EXT_ALLOCATORS_BLOB_HEADER #define EXT_ALLOCATORS_BLOB_HEADER -#include "detail_block.hpp" -#include +#include "memory_block.hpp" #include #include namespace EXT_ALLOCATOR_NAMESPACE { template -class alignas(Alignment) blob_allocator { - public: + +class alignas(Alignment) blob_allocator +{ +public: static constexpr std::size_t memory_size = MemorySize; static constexpr std::size_t memory_alignment = Alignment; @@ -17,14 +18,6 @@ class alignas(Alignment) blob_allocator { blob_allocator(blob_allocator const&) = delete; blob_allocator(blob_allocator&&) = delete; - static constexpr std::size_t actual_size(std::size_t alignment, std::size_t size) noexcept { - return size <= memory_size && alignment <= memory_alignment ? memory_size : 0; - } - - bool owns(memory_block block) EXTALLOC_NOEXCEPT { - return owns_block(_data, memory_size, block); - } - memory_block allocate(std::size_t alignment, std::size_t size) noexcept { memory_block out{nullptr, 0}; if (size <= memory_size) @@ -39,6 +32,14 @@ class alignas(Alignment) blob_allocator { _allocated = false; } + static constexpr std::size_t actual_size(std::size_t alignment, std::size_t size) noexcept { + return size <= memory_size && alignment <= memory_alignment ? memory_size : 0; + } + + bool owns(memory_block block) EXTALLOC_NOEXCEPT { + return owns_block(_data, memory_size, block); + } + memory_block allocate_all(std::size_t alignment) noexcept { memory_block out{nullptr, 0}; @@ -54,7 +55,7 @@ class alignas(Alignment) blob_allocator { _allocated = false; } - private: +private: std::byte _data[memory_size]; bool _allocated; }; diff --git a/include/ext/allocators/cascading.hpp b/include/ext/allocators/cascading.hpp index 23c074b..4f2a744 100644 --- a/include/ext/allocators/cascading.hpp +++ b/include/ext/allocators/cascading.hpp @@ -1,8 +1,7 @@ #ifndef EXT_ALLOCATORS_CASCADING_HEADER #define EXT_ALLOCATORS_CASCADING_HEADER -#include "detail_block.hpp" -#include "detail_traits.hpp" +#include "memory_block.hpp" #include "stl_wrapper.hpp" #include @@ -11,58 +10,13 @@ #include namespace EXT_ALLOCATOR_NAMESPACE { -namespace _detail_cascading_allocator { -template -class extension_allocate_array { - protected: - template - std::tuple allocate_helper( - ChildAllocator& allocator, std::size_t alignment, std::size_t size, std::size_t count, OutItr out_itr) { - (void) count; // FIXME - assert(count == 1); - memory_block block = allocator.allocate(alignment, size); - if (block.data) { - *out_itr++ = block; - return {out_itr, true}; - } else - return {out_itr, false}; - } -}; - -template -class extension_allocate_array>> { - public: - template - std::tuple - allocate_array(std::size_t alignment, std::size_t size, std::size_t count, OutItr out_itr) { - return static_cast(this)->allocate_impl(alignment, size, count, out_itr); - } - - protected: - template - std::tuple allocate_helper( - ChildAllocator& allocator, std::size_t alignment, std::size_t size, std::size_t count, OutItr out_itr) { - return allocator.allocate_array(alignment, size, count, out_itr); - } -}; -} // namespace _detail_cascading_allocator /// creates ChildAllocator objects in the memory pool of ParentAllocator as needed + template -class cascading_allocator - : public _detail_cascading_allocator::extension_allocate_array, - ChildAllocator> - , private ParentAllocator { - private: - using base = - _detail_cascading_allocator::extension_allocate_array, - ChildAllocator>; - friend base; - using base::allocate_helper; - - public: +class cascading_allocator : private ParentAllocator +{ +public: using parent_allocator_t = ParentAllocator; using child_allocator_t = ChildAllocator; @@ -92,7 +46,7 @@ class cascading_allocator itr->deallocate(block); } - private: +private: template std::tuple allocate_impl(std::size_t alignment, std::size_t size, std::size_t count, OutItr out_itr) { std::tuple result{out_itr, false}; diff --git a/include/ext/allocators/detail_traits.hpp b/include/ext/allocators/detail_traits.hpp deleted file mode 100644 index 7e1a919..0000000 --- a/include/ext/allocators/detail_traits.hpp +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef EXT_ALLOCATORS_DETAIL_TRAITS_HEADER -#define EXT_ALLOCATORS_DETAIL_TRAITS_HEADER - -#include "config.hpp" -#include "detail_block.hpp" -#include - -namespace EXT_ALLOCATOR_NAMESPACE { namespace _detail { - -template -struct has_allocate_array : std::false_type {}; - -inline memory_block* traits_helper{}; -template -struct has_allocate_array< - T, - std::void_t().allocate_array(std::size_t{}, std::size_t{}, std::size_t{}, traits_helper))>> - : std::true_type {}; - -template -inline bool has_allocate_array_v = has_allocate_array::value; - -}} // namespace EXT_ALLOCATOR_NAMESPACE::_detail - -#endif // EXT_ALLOCATORS_DETAIL_TRAITS_HEADER diff --git a/include/ext/allocators/fallback.hpp b/include/ext/allocators/fallback.hpp index fac49b0..b6088be 100644 --- a/include/ext/allocators/fallback.hpp +++ b/include/ext/allocators/fallback.hpp @@ -1,42 +1,18 @@ #ifndef EXT_ALLOCATORS_FALLBACK_HEADER #define EXT_ALLOCATORS_FALLBACK_HEADER -#include "detail_block.hpp" -#include "detail_traits.hpp" +#include "memory_block.hpp" #include +#include namespace EXT_ALLOCATOR_NAMESPACE { -namespace _detail_fallback_allocator { -template -struct extension_allocate_array {}; - -template -struct extension_allocate_array< - Derived, - FirstAllocator, - SecondAllocator, - std::enable_if_t<_detail::has_allocate_array_v && _detail::has_allocate_array_v>> { - - template - std::tuple - allocate_array(std::size_t alignment, std::size_t size, std::size_t count, OutItr out_itr) { - auto* parent = static_cast(this); - auto result = static_cast(parent)->allocate_array(alignment, size, count, out_itr); - if (!std::get<1>(result)) - result = static_cast(parent)->allocate_array(alignment, size, count, out_itr); - - return result; - } -}; -} // namespace _detail_fallback_allocator template class fallback_allocator - : public _detail_fallback_allocator:: - extension_allocate_array, FirstAllocator, SecondAllocator> - , private FirstAllocator - , private SecondAllocator { - public: + : private FirstAllocator + , private SecondAllocator +{ +public: static constexpr std::size_t actual_size(std::size_t alignment, std::size_t size) { return FirstAllocator::actual_size(alignment, size) == SecondAllocator::actual_size(alignment, size) ? FirstAllocator::actual_size(alignment, size) diff --git a/include/ext/allocators/detail_block.hpp b/include/ext/allocators/memory_block.hpp similarity index 84% rename from include/ext/allocators/detail_block.hpp rename to include/ext/allocators/memory_block.hpp index d9b8171..2e3e273 100644 --- a/include/ext/allocators/detail_block.hpp +++ b/include/ext/allocators/memory_block.hpp @@ -13,6 +13,12 @@ namespace EXT_ALLOCATOR_NAMESPACE { +template +std::enable_if_t, T> +inline constexpr align_up(T addr, std::size_t alignment) { + return reinterpret_cast(((reinterpret_cast(addr) + (alignment - 1)) / alignment) * alignment); +} + struct memory_block; inline bool owns_block(std::byte const* data, std::size_t size, memory_block const& block) EXTALLOC_NOEXCEPT; @@ -25,12 +31,13 @@ struct memory_block { return data != nullptr; } - std::byte* data; - std::size_t size; - bool owns(memory_block const& other) const EXTALLOC_NOEXCEPT { return owns_block(data, size, other); }; + + std::byte* data; // pointer to data + std::size_t size; // byte size + }; inline bool owns_block(std::byte const* data, std::size_t size, memory_block const& block) EXTALLOC_NOEXCEPT { diff --git a/include/ext/allocators/null.hpp b/include/ext/allocators/null.hpp index 7092b06..fed4e52 100644 --- a/include/ext/allocators/null.hpp +++ b/include/ext/allocators/null.hpp @@ -1,7 +1,7 @@ #ifndef EXT_ALLOCATORS_NULL_HEADER #define EXT_ALLOCATORS_NULL_HEADER -#include "detail_block.hpp" +#include "memory_block.hpp" #include namespace EXT_ALLOCATOR_NAMESPACE { @@ -25,10 +25,6 @@ struct null_allocator { assert(block.data == nullptr); } - // bool expand(memory_block&, std::size_t /* new_size */) { - // return false; - //} - memory_block allocate_all(std::size_t /* alignment */) { return {nullptr, 0}; } diff --git a/include/ext/allocators/singleton.hpp b/include/ext/allocators/singleton.hpp index c16bc46..eebe101 100644 --- a/include/ext/allocators/singleton.hpp +++ b/include/ext/allocators/singleton.hpp @@ -1,36 +1,26 @@ #ifndef EXT_ALLOCATORS_SINGLETON_HEADER #define EXT_ALLOCATORS_SINGLETON_HEADER -#include "detail_block.hpp" -#include "detail_traits.hpp" +#include "memory_block.hpp" #include #include namespace EXT_ALLOCATOR_NAMESPACE { -namespace _detail_singleton_allocator { -template -struct extension_allocate_array {}; - -template -struct extension_allocate_array>> { - template - std::tuple - allocate_array(std::size_t alignment, std::size_t size, std::size_t count, OutItr out_itr) { - auto* parent = static_cast(this); - return parent->instance().allocate_array(alignment, size, count, out_itr); - } -}; -} // namespace _detail_singleton_allocator /// creates a thread_local instance of the given allocator type, which will used by any instance of this allocator /** \note The instance of Allocator will be created as a thread_local static function variable. */ template -struct singleton_allocator - : public _detail_singleton_allocator::extension_allocate_array, Allocator> { +struct singleton_allocator { using allocator_t = Allocator; + /// returns the global thread_local instance of allocator_t + static allocator_t& instance() { + thread_local static allocator_t a; + return a; + } + /// returns the actual size for the requested size and alignment /** \note If the size cannot be determined at compile time, the returned size is @@ -44,12 +34,6 @@ struct singleton_allocator return instance().owns(block); } - /// returns the global thread_local instance of allocator_t - static allocator_t& instance() { - thread_local static allocator_t a; - return a; - } - memory_block allocate(std::size_t alignment, std::size_t size) { return instance().allocate(alignment, size); } diff --git a/include/ext/allocators/size_segregator.hpp b/include/ext/allocators/size_segregator.hpp index 3b06f48..56465a2 100644 --- a/include/ext/allocators/size_segregator.hpp +++ b/include/ext/allocators/size_segregator.hpp @@ -1,50 +1,18 @@ #ifndef EXT_ALLOCATORS_SIZE_SEGREGATOR_HEADER #define EXT_ALLOCATORS_SIZE_SEGREGATOR_HEADER -#include "detail_block.hpp" -#include "detail_traits.hpp" +#include "memory_block.hpp" #include namespace EXT_ALLOCATOR_NAMESPACE { -namespace _detail_size_segregator { -template -struct extension_allocate_array {}; - -template -struct extension_allocate_array< - Derived, - FirstAllocator, - SecondAllocator, - SizeLessOrEqual, - std::enable_if_t<_detail::has_allocate_array_v && _detail::has_allocate_array_v>> { - template - std::tuple - allocate_array(std::size_t alignment, std::size_t size, std::size_t count, OutItr out_itr) { - auto* parent = static_cast(this); - if (size <= SizeLessOrEqual) { - return static_cast(parent)->allocate_array(alignment, size, count, out_itr); - } else { - return static_cast(parent)->allocate_array(alignment, size, count, out_itr); - } - } -}; -} // namespace _detail_size_segregator template struct size_segregator - : public _detail_size_segregator::extension_allocate_array< - size_segregator, - FirstAllocator, - SecondAllocator, - SizeLessOrEqual> - , private FirstAllocator + : private FirstAllocator , private SecondAllocator { - // using first_allocator = FirstAllocator; - // using second_allocator = SecondAllocator; + + using first_allocator = FirstAllocator; + using second_allocator = SecondAllocator; static constexpr std::size_t dividing_size = SizeLessOrEqual; diff --git a/include/ext/allocators/stack.hpp b/include/ext/allocators/stack.hpp index 829861a..54b34d6 100644 --- a/include/ext/allocators/stack.hpp +++ b/include/ext/allocators/stack.hpp @@ -1,10 +1,8 @@ #ifndef EXT_ALLOCATORS_STACK_HEADER #define EXT_ALLOCATORS_STACK_HEADER -#include "detail_block.hpp" -//#include +#include "memory_block.hpp" #include -//#include namespace EXT_ALLOCATOR_NAMESPACE { /// allocates memory in a stack like manner @@ -14,7 +12,7 @@ namespace EXT_ALLOCATOR_NAMESPACE { */ template class stack_allocator : ParentAllocator { - public: +public: static constexpr std::size_t memory_size = MemorySize; static constexpr std::size_t memory_alignment = Alignment; @@ -50,16 +48,18 @@ class stack_allocator : ParentAllocator { } memory_block allocate(std::size_t alignment, std::size_t size) { - if (!_start) + if(!_start) init(); memory_block out{nullptr, 0}; // refuses alignments greater than memory_alignment - if (_cur && alignment <= memory_alignment) { - size = static_cast(boost::alignment::align_up(_cur + size, memory_alignment) - _cur); - out = {_cur, size}; - _cur += size; + if(_cur == nullptr) { + auto* aligned_ptr = align_up(_cur, alignment); + if(aligned_ptr + size < _end) { + out = {aligned_ptr, size}; + _cur += size; + } } return out; @@ -72,8 +72,8 @@ class stack_allocator : ParentAllocator { init(); if (_start && alignment <= memory_alignment) { - out = {ptr, _end - ptr}; - _ptr = _end; + out = {_cur, _end - _cur}; + _cur = _end; } return out; @@ -92,17 +92,17 @@ class stack_allocator : ParentAllocator { return block.data >= _start && block.data + block.size <= _end; } - private: +private: void init() { auto block = ParentAllocator::allocate(memory_size, memory_alignment); _end = _start = _cur = block.data; _end += block.size; } - private: - char* _start; - char* _cur; - char* _end; +private: + std::byte* _start; + std::byte* _cur; + std::byte* _end; }; } // namespace EXT_ALLOCATOR_NAMESPACE diff --git a/include/ext/allocators/standard.hpp b/include/ext/allocators/standard.hpp index 7cdfa3b..b8a3530 100644 --- a/include/ext/allocators/standard.hpp +++ b/include/ext/allocators/standard.hpp @@ -1,7 +1,7 @@ #ifndef EXT_ALLOCATORS_STANDARD_HEADER #define EXT_ALLOCATORS_STANDARD_HEADER -#include "detail_block.hpp" +#include "memory_block.hpp" #include #include @@ -13,6 +13,7 @@ class standard_allocator { return size; } + // can not tell - unfortunately bool owns(memory_block) const noexcept { return true; } diff --git a/include/ext/allocators/stl_wrapper.hpp b/include/ext/allocators/stl_wrapper.hpp index c4159b3..2a4a402 100644 --- a/include/ext/allocators/stl_wrapper.hpp +++ b/include/ext/allocators/stl_wrapper.hpp @@ -1,8 +1,7 @@ #ifndef EXT_ALLOCATORS_STL_WRAPPER_HEADER #define EXT_ALLOCATORS_STL_WRAPPER_HEADER -#include "detail_block.hpp" -#include +#include "memory_block.hpp" #include #include diff --git a/tests/test_blob_allocator.cpp b/tests/test_blob_allocator.cpp index 4f9f5c5..ee4089f 100644 --- a/tests/test_blob_allocator.cpp +++ b/tests/test_blob_allocator.cpp @@ -5,6 +5,8 @@ #undef private TEST(blob, test_allocate) { + + // allocate in memory of 64bit with alignment of 8bit EXT_ALLOCATOR_NAMESPACE::blob_allocator<8, 64> a; auto block = a.allocate(8, 64); diff --git a/tests/test_memblock.cpp b/tests/test_memblock.cpp index 776857a..2d9286c 100644 --- a/tests/test_memblock.cpp +++ b/tests/test_memblock.cpp @@ -1,8 +1,8 @@ #include -#include - +#include #include + #define private public #include #include