CppCommon  1.0.4.1
C++ Common Library
memory_arena.cpp

Arena memory allocator example

#include <iostream>
int main(int argc, char** argv)
{
int* v = alloc.Create(123);
std::cout << "v = " << *v << std::endl;
alloc.Release(v);
int* a = alloc.CreateArray(3, 123);
std::cout << "a[0] = " << a[0] << std::endl;
std::cout << "a[1] = " << a[1] << std::endl;
std::cout << "a[2] = " << a[2] << std::endl;
alloc.ReleaseArray(a);
return 0;
}
Arena memory allocator definition.
Memory allocator class.
Definition: allocator.h:25
void ReleaseArray(T *ptr)
Release an array of element objects.
Definition: allocator.inl:124
void Release(T *ptr)
Release a single element object.
Definition: allocator.inl:85
T * CreateArray(size_t length, Args &&... args)
Create an array of element objects.
Definition: allocator.inl:102
T * Create(Args &&... args)
Create a single element object.
Definition: allocator.inl:72
Arena memory manager class.
Default memory manager class.
Definition: allocator.h:187