metaforce/Runtime/CGameAllocator.hpp

31 lines
588 B
C++
Raw Normal View History

2018-10-06 20:42:33 -07:00
#pragma once
#include <cstddef>
#include <memory>
#include <vector>
#include "Runtime/RetroTypes.hpp"
2021-04-10 01:42:06 -07:00
namespace metaforce {
2018-12-07 21:30:43 -08:00
class CGameAllocator {
struct SAllocationDescription {
std::unique_ptr<u8[]> memptr;
size_t allocSize = 0;
ptrdiff_t freeOffset = 0;
};
2018-12-07 21:30:43 -08:00
struct SChunkDescription {
u32 magic = 0xE8E8E8E8;
SAllocationDescription* parent;
size_t len = 0;
u32 sentinal = 0xEFEFEFEF;
};
2018-12-07 21:30:43 -08:00
static std::vector<SAllocationDescription> m_allocations;
public:
2018-12-07 21:30:43 -08:00
static u8* Alloc(size_t len);
static void Free(u8* ptr);
};
2021-04-10 01:42:06 -07:00
} // namespace metaforce