custom_memory_allocator
最終更新
役に立ちましたか?
役に立ちましたか?
/**
* This is a sample implementation of the custom allocator.
* The user can implement their own custom allocator by inheriting Diarkis::ICustomAllocator.
*/
class SampleCustomAllocator : public Diarkis::ICustomAllocator
{
public:
...void* Allocate(size_t size, int flag) override
{
...
return ptr;
}
void* AlignedAllocate(size_t size, size_t align, int flag) override
{
...
return ptr;
}
void Deallocate(void* ptr) override
{
...
}// Replace the default allocator of the Diarkis runtime with the custom allocator user implemented.
// You need to set the custom allocator before calling any Diarkis runtime functions.
Diarkis::SetCustomAllocator(&gCustomAllocator);