12#ifndef ECS__I_ALLOC_H__
13#define ECS__I_ALLOC_H__
17namespace ECS {
namespace Memory {
namespace Allocator {
23 return (
void*)((
reinterpret_cast<uptr>(address)+
static_cast<uptr>(alignment - 1)) &
static_cast<uptr>(~(alignment - 1)));
29 const u8 adjustment = alignment - (
reinterpret_cast<uptr>(address)&
static_cast<uptr>(alignment - 1));
31 return adjustment == alignment ? 0 : adjustment;
38 u8 neededSpace = extra;
40 if (adjustment < neededSpace)
42 neededSpace -= adjustment;
45 adjustment += alignment * (neededSpace / alignment);
47 if (neededSpace % alignment > 0)
48 adjustment += alignment;
67 IAllocator(
const size_t memSize,
const void* mem);
71 virtual void free(
void* p) = 0;
77 return this->m_MemorySize;
82 return this->m_MemoryFirstAddress;
87 return this->m_MemoryUsed;
92 return this->m_MemoryAllocations;
const size_t m_MemorySize
u64 GetAllocationCount() const
virtual void free(void *p)=0
size_t GetMemorySize() const
size_t GetUsedMemory() const
const void * GetMemoryAddress0() const
virtual void * allocate(size_t size, u8 alignment)=0
const void * m_MemoryFirstAddress
static void * AlignForward(void *address, u8 alignment)
static u8 GetAdjustment(const void *address, u8 alignment)