35 lines
554 B
C++
35 lines
554 B
C++
#pragma once
|
|
|
|
#include <cstdint>
|
|
|
|
#include "MacroUtils.h"
|
|
|
|
using Byte = uint8_t;
|
|
|
|
struct GlobalMemory
|
|
{
|
|
struct State
|
|
{
|
|
Byte* memory;
|
|
size_t available;
|
|
};
|
|
|
|
Byte* memory;
|
|
size_t available;
|
|
size_t capacity;
|
|
|
|
void init( size_t size );
|
|
|
|
void destroy();
|
|
|
|
Byte* allocate( size_t size );
|
|
|
|
Byte* allocate( size_t size, size_t alignment );
|
|
|
|
// Do not do any permanent allocations after calling this.
|
|
[[nodiscard]] State getState() const;
|
|
|
|
// Call this before permanent allocations.
|
|
void restoreState( State const& state );
|
|
};
|