Constructor
| 33 | |
| 34 | // Constructor |
| 35 | SingleFrameAllocator::SingleFrameAllocator(MemoryAllocator& baseAllocator) : mBaseAllocator(baseAllocator), |
| 36 | mTotalSizeBytes(INIT_SINGLE_FRAME_ALLOCATOR_NB_BYTES), |
| 37 | mCurrentOffset(0), mNeedToAllocatedMore(false) { |
| 38 | |
| 39 | // Allocate a whole block of memory at the beginning |
| 40 | void* allocatedMemory = mBaseAllocator.allocate(mTotalSizeBytes); |
| 41 | |
| 42 | assert(allocatedMemory != nullptr); |
| 43 | |
| 44 | // Check that allocated memory is 16-bytes aligned |
| 45 | assert(reinterpret_cast<uintptr_t>(allocatedMemory) % GLOBAL_ALIGNMENT == 0); |
| 46 | |
| 47 | mMemoryBufferStart = static_cast<char*>(allocatedMemory); |
| 48 | } |
| 49 | |
| 50 | // Destructor |
| 51 | SingleFrameAllocator::~SingleFrameAllocator() { |