15 #include <vsg/core/Inherit.h>
24 uint8_t* buffer =
nullptr;
25 uint8_t* ptr =
nullptr;
33 buffer =
new uint8_t[bufferSize];
45 uint8_t* align(uint8_t* p)
const
47 auto alignment =
sizeof(p);
48 uint8_t* new_p =
reinterpret_cast<uint8_t*
>(((
reinterpret_cast<size_t>(p) + alignment - 1) / alignment) * alignment);
53 T* allocate(
size_t num = 1)
55 if (num == 0)
return nullptr;
57 size_t allocate_size =
sizeof(T) * num;
59 if ((ptr + allocate_size) <= (buffer + size))
61 T* allocated_ptr =
reinterpret_cast<T*
>(ptr);
64 ptr = align(ptr + allocate_size);
69 if (!next) next = ScratchMemory::create(std::max(size, allocate_size));
71 return next->allocate<T>(num);
77 if (next) next->release();
Definition: ScratchMemory.h:23