34 lines
549 B
C++
34 lines
549 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 const size);
|
|
|
|
void destroy();
|
|
|
|
Byte* allocate(size_t const size);
|
|
|
|
Byte* allocate(size_t const size, size_t const alignment);
|
|
|
|
// Do not do any permanent allocations after calling this.
|
|
[[nodiscard]] State getState() const;
|
|
|
|
// Call this before permanent allocations.
|
|
void restoreState(State const& state);
|
|
}; |