3 #include "../utility/assert.h"
4 #include "../utility/alignment.h"
61 return m_Data == rhs.m_Data;
66 return m_Data != rhs.m_Data;
69 #pragma region Allocation
79 if ((
size_t(m_Free - m_Data) + totalSize) > Size)
82 char* current = m_Free;
85 m_ObjectCount += totalSize;
102 if (m_Free - totalSize == p)
105 m_ObjectCount -= totalSize;
108 if (m_ObjectCount == 0)
113 #pragma region Utility
128 bool owns(
void* p)
const noexcept
132 uintptr_t ptr =
reinterpret_cast<uintptr_t
>(p);
133 uintptr_t low =
reinterpret_cast<uintptr_t
>(m_Data);
134 uintptr_t high = low + Size;
136 return ptr >= low && ptr < high;
143 size_t m_ObjectCount;
#define KTL_ASSERT(x)
Definition: assert.h:17
A linear allocator which gives out chunks of its internal stack. Increments a counter during allocati...
Definition: linear_allocator.h:19
linear_allocator & operator=(const linear_allocator &) noexcept=delete
linear_allocator & operator=(linear_allocator &&rhs) noexcept
Move assignment operator.
Definition: linear_allocator.h:49
bool owns(void *p) const noexcept
Returns whether or not the allocator owns the given location in memory.
Definition: linear_allocator.h:128
void deallocate(void *p, size_t n) noexcept
Attempts to deallocate the memory at location p.
Definition: linear_allocator.h:96
linear_allocator() noexcept
Definition: linear_allocator.h:21
void * allocate(size_t n) noexcept
Attempts to allocate a chunk of memory defined by n.
Definition: linear_allocator.h:75
bool operator==(const linear_allocator &rhs) const noexcept
Definition: linear_allocator.h:59
bool operator!=(const linear_allocator &rhs) const noexcept
Definition: linear_allocator.h:64
size_t max_size() const noexcept
Returns the maximum size that an allocation can be.
Definition: linear_allocator.h:118
linear_allocator(const linear_allocator &) noexcept=delete
linear_allocator(linear_allocator &&other) noexcept
Move constructor.
Definition: linear_allocator.h:33
constexpr size_t align_to_architecture(size_t n) noexcept
Definition: alignment.h:10
constexpr size_t ALIGNMENT
Definition: alignment.h:7
Definition: cascading.h:15