2023-04-01 19:21:46 -07:00
|
|
|
#define BLOAT_IMPL
|
2023-04-01 22:07:44 -07:00
|
|
|
#include "Bloat.hpp"
|
2023-04-01 19:21:46 -07:00
|
|
|
|
2023-04-03 23:04:19 -07:00
|
|
|
|
2023-04-01 19:21:46 -07:00
|
|
|
namespace Memory
|
|
|
|
{
|
2023-04-09 10:59:39 -07:00
|
|
|
using namespace zpl;
|
|
|
|
|
|
|
|
Arena Global_Arena {};
|
2023-04-05 23:21:23 -07:00
|
|
|
|
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-05 23:21:23 -07:00
|
|
|
|
2023-04-01 19:21:46 -07:00
|
|
|
void resize( uw new_size )
|
|
|
|
{
|
2023-04-05 23:21:23 -07:00
|
|
|
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-05 23:21:23 -07:00
|
|
|
|
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-05 23:21:23 -07:00
|
|
|
}
|
2023-04-01 19:21:46 -07:00
|
|
|
}
|