2020-08-17 21:40:52 +02:00
|
|
|
#include <Platform.h> // Only use angled for Platform, else, xcode project won't compile
|
2020-02-15 15:51:18 +01:00
|
|
|
|
|
|
|
#if 0
|
|
|
|
#define DBG(...) DebugLog(2, __VA_ARGS__)
|
|
|
|
#else
|
|
|
|
#define DBG(...)
|
|
|
|
#endif
|
|
|
|
|
2020-02-21 10:44:15 +01:00
|
|
|
#if defined(_MSC_VER)
|
|
|
|
void* operator new (size_t count)
|
|
|
|
#else
|
2021-04-16 11:55:51 +02:00
|
|
|
void* operator new(unsigned long count)
|
2020-02-21 10:44:15 +01:00
|
|
|
#endif
|
2020-02-15 15:51:18 +01:00
|
|
|
{
|
|
|
|
void* ptr = AllocatePool(count);
|
|
|
|
if ( !ptr ) {
|
2020-03-25 19:32:44 +01:00
|
|
|
DebugLog(2, "AllocatePool(%lu) returned NULL. Cpu halted\n", count);
|
2020-02-15 15:51:18 +01:00
|
|
|
CpuDeadLoop();
|
|
|
|
}
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
|
2020-08-09 17:55:30 +02:00
|
|
|
#if defined(_MSC_VER)
|
2021-04-16 11:55:51 +02:00
|
|
|
void* operator new[](size_t count)
|
2020-08-09 17:55:30 +02:00
|
|
|
#else
|
2021-04-16 11:55:51 +02:00
|
|
|
void* operator new[](unsigned long count)
|
2020-08-09 17:55:30 +02:00
|
|
|
#endif
|
|
|
|
{
|
|
|
|
void* ptr = AllocatePool(count);
|
|
|
|
if ( !ptr ) {
|
|
|
|
DebugLog(2, "AllocatePool(%lu) returned NULL. Cpu halted\n", count);
|
|
|
|
CpuDeadLoop();
|
|
|
|
}
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
|
2020-02-25 14:55:39 +01:00
|
|
|
#ifdef _MSC_VER
|
2020-02-25 11:29:33 +01:00
|
|
|
#pragma warning(disable : 4577)
|
2020-02-25 14:55:39 +01:00
|
|
|
#endif
|
2020-02-15 15:51:18 +01:00
|
|
|
void operator delete ( void* ptr ) noexcept
|
|
|
|
{
|
|
|
|
return FreePool(ptr);
|
|
|
|
}
|
2020-11-02 14:45:11 +01:00
|
|
|
|
2020-02-25 18:42:06 +01:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
void _cdecl operator delete (void * ptr, unsigned __int64 count)
|
|
|
|
#else
|
|
|
|
void operator delete (void * ptr, UINTN count)
|
|
|
|
#endif
|
2020-02-25 11:29:33 +01:00
|
|
|
{
|
|
|
|
return FreePool(ptr);
|
|
|
|
}
|
|
|
|
|
2020-02-15 15:51:18 +01:00
|
|
|
|
2020-11-02 14:45:11 +01:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
void _cdecl operator delete[](void * ptr, unsigned __int64 count)
|
|
|
|
#else
|
|
|
|
void operator delete[](void * ptr, UINTN count)
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
return FreePool(ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|