xo-alloc2: + Allocator.alloc_range() with DArena input
This commit is contained in:
parent
d8ed0d6235
commit
181ae9f12b
13 changed files with 158 additions and 59 deletions
|
|
@ -59,6 +59,14 @@ namespace xo {
|
|||
**/
|
||||
static DArenaIterator end(const DArena * arena);
|
||||
|
||||
/** Address of allocation header for beginning of alloc range in @p arena **/
|
||||
static AllocHeader * begin_header(const DArena * arena);
|
||||
/** Address of allocation header for end of alloc range.
|
||||
* This is the address of header for _next_ allocation in @p arena
|
||||
* i.e. free pointer
|
||||
**/
|
||||
static AllocHeader * end_header(const DArena * arena);
|
||||
|
||||
/** A valid iterator can be compared, at least with itself
|
||||
* It can be dereferenced if is also non-empty
|
||||
**/
|
||||
|
|
|
|||
|
|
@ -19,15 +19,20 @@ namespace xo {
|
|||
}
|
||||
|
||||
namespace mm {
|
||||
/* changes here coordinate with:
|
||||
* AAllocator AAllocator.hpp
|
||||
* IAllocator_Any IAllocator_Any.hpp
|
||||
* IAllocator_Xfer IAllocator_Xfer.hpp
|
||||
* RAllocator RAllocator.hpp
|
||||
*/
|
||||
/** @class IAllocator_DArena
|
||||
* @brief Provide AAllocator interface for DArena state
|
||||
**/
|
||||
struct IAllocator_DArena {
|
||||
/* changes here coordinate with:
|
||||
* AAllocator AAllocator.hpp
|
||||
* IAllocator_Any IAllocator_Any.hpp
|
||||
* IAllocator_Xfer IAllocator_Xfer.hpp
|
||||
* RAllocator RAllocator.hpp
|
||||
*/
|
||||
using size_type = std::size_t;
|
||||
using value_type = std::byte *;
|
||||
using range_type = std::pair<obj<AAllocIterator>,
|
||||
obj<AAllocIterator>>;
|
||||
|
||||
enum class alloc_mode : uint8_t {
|
||||
standard,
|
||||
|
|
@ -44,9 +49,13 @@ namespace xo {
|
|||
static size_type allocated(const DArena &) noexcept;
|
||||
static bool contains(const DArena &, const void * p) noexcept;
|
||||
static AllocError last_error(const DArena &) noexcept;
|
||||
|
||||
/** retrieve allocation bookkeeping info for @p mem from arena @p d **/
|
||||
static AllocInfo alloc_info(const DArena &, value_type mem) noexcept;
|
||||
/** create alloc-iterator range over allocs on @d,
|
||||
* Iterators themselves allocated from @p ialloc.
|
||||
**/
|
||||
static range_type alloc_range(const DArena & d, DArena & ialloc) noexcept;
|
||||
|
||||
/** expand committed space in arena @p d
|
||||
* to size at least @p z
|
||||
* In practice will round up to a multiple of @ref page_z_.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue