gencpp/project/Bloat.cpp

39 lines
685 B
C++
Raw Normal View History

2023-04-01 19:21:46 -07:00
#define BLOAT_IMPL
#include "Bloat.hpp"
2023-04-01 19:21:46 -07:00
2023-04-01 19:21:46 -07:00
namespace Memory
{
using namespace zpl;
Arena Global_Arena {};
2023-04-01 19:21:46 -07:00
void setup()
{
arena_init_from_allocator( & Global_Arena, heap(), Initial_Reserve );
if ( Global_Arena.total_size == 0 )
{
assert_crash( "Failed to reserve memory for Tests:: Global_Arena" );
}
}
2023-04-01 19:21:46 -07:00
void resize( uw new_size )
{
void* new_memory = resize( heap(), Global_Arena.physical_start, Global_Arena.total_size, new_size );
2023-04-01 19:21:46 -07:00
if ( new_memory == nullptr )
{
fatal("Failed to resize global arena!");
}
2023-04-01 19:21:46 -07:00
Global_Arena.physical_start = new_memory;
Global_Arena.total_size = new_size;
}
void cleanup()
{
arena_free( & Global_Arena);
}
2023-04-01 19:21:46 -07:00
}