3#include <Common/Memory/Allocators/DynamicAllocator.hpp>
4#include <Common/String.hpp>
6namespace Grindstone::Memory::AllocatorCore {
14 bool Initialize(
size_t sizeInMegs);
15 void CloseAllocator();
17 StringRef AllocateString(
size_t size);
18 StringRef AllocateString(Grindstone::StringRef srcString);
20 bool FreeWithoutDestructor(
void* memPtr);
28 void* AllocateRaw(
size_t size,
size_t alignment,
const char* debugName);
30 template<
typename T,
typename... Args>
32 return static_cast<T*
>(GetAllocatorState()->dynamicAllocator.AllocateUnique<T>(params));
35 template<
typename T,
typename... Args>
37 return static_cast<T*
>(GetAllocatorState()->dynamicAllocator.AllocateShared<T>(params));
40 template<
typename T,
typename... Args>
41 T* Allocate(Args&&... params) {
42 T* ptr =
static_cast<T*
>(GetAllocatorState()->dynamicAllocator.AllocateRaw(
sizeof(T),
alignof(T),
typeid(T).name()));
45 new (ptr) T(std::forward<Args>(params)...);
52 bool Free(T* memPtr) {
53 if (memPtr ==
nullptr) {
57 reinterpret_cast<T*
>(memPtr)->~T();
58 GetAllocatorState()->dynamicAllocator.Free(memPtr);
A dynamic allocator represented by a linked list.
Definition DynamicAllocator.hpp:19
Definition SharedPtr.hpp:5
Definition UniquePtr.hpp:7
Definition MemoryAllocator.hpp:7