#include "deimos/core/allocator.h" #include namespace deimos { class SystemAllocatorImpl : public IAllocator { public: SystemAllocatorImpl() : IAllocator(MemoryScope{0}) {} void* Reallocate( void* old_ptr, int64 /* old_size */, int64 new_size, const char* /* file */, int32 /* line */) override { if (old_ptr == nullptr) { return new_size > 0 ? ::malloc((uint64)new_size) : nullptr; } if (new_size == 0) { if (old_ptr != nullptr) { ::free(old_ptr); } } else { return ::realloc(old_ptr, (uint64)new_size); } return nullptr; } }; class AllocatorApiImpl : public AllocatorApi { SystemAllocatorImpl m_system_impl; public: AllocatorApiImpl() { system = &m_system_impl; } }; AllocatorApi* BootstrapAllocatorApi() { static AllocatorApiImpl g_instance{}; return &g_instance; } } // namespace deimos