text
stringlengths
0
2.2M
_Ret_notnull_ _Post_writable_byte_size_(size) void* operator new[](size_t size)
{
gEASTLTest_AllocationCount++;
gEASTLTest_TotalAllocationCount++;
void* mem = InternalMalloc(size);
#if !defined(EA_COMPILER_NO_EXCEPTIONS)
if (mem == NULL)
{
throw std::bad_alloc();
}
#endif
return mem;
}
void* operator new[](size_t size, const char* name, int flags, unsigned debugFlags, const char* file, int line)
{
gEASTLTest_AllocationCount++;
gEASTLTest_TotalAllocationCount++;
return InternalMalloc(size, name, flags, debugFlags, file, line);
}
void* operator new[](size_t size, size_t alignment, size_t alignmentOffset, const char* name, int flags, unsigned debugFlags, const char* file, int line)
{
gEASTLTest_AllocationCount++;
gEASTLTest_TotalAllocationCount++;
return InternalMalloc(size, alignment, name, flags, debugFlags, file, line);
}
// Used by GCC when you make new objects of classes with >= N bit alignment (with N depending on the compiler).
void* operator new(size_t size, size_t alignment)
{
gEASTLTest_AllocationCount++;
gEASTLTest_TotalAllocationCount++;
return InternalMalloc(size, alignment);
}
// Used by GCC when you make new objects of classes with >= N bit alignment (with N depending on the compiler).
void* operator new(size_t size, size_t alignment, const std::nothrow_t&) EA_THROW_SPEC_NEW_NONE()
{
gEASTLTest_AllocationCount++;
gEASTLTest_TotalAllocationCount++;
return InternalMalloc(size, alignment);
}
// Used by GCC when you make new objects of classes with >= N bit alignment (with N depending on the compiler).
void* operator new[](size_t size, size_t alignment)
{
gEASTLTest_AllocationCount++;
gEASTLTest_TotalAllocationCount++;
return InternalMalloc(size, alignment);
}
// Used by GCC when you make new objects of classes with >= N bit alignment (with N depending on the compiler).
void* operator new[](size_t size, size_t alignment, const std::nothrow_t&) EA_THROW_SPEC_NEW_NONE()
{
gEASTLTest_AllocationCount++;
gEASTLTest_TotalAllocationCount++;
return InternalMalloc(size, alignment);
}
void operator delete(void* p) EA_THROW_SPEC_DELETE_NONE()
{
if(p) // The standard specifies that 'delete NULL' is a valid operation.
{
gEASTLTest_AllocationCount--;
InternalFree(p);
}
}
void operator delete[](void* p) EA_THROW_SPEC_DELETE_NONE()
{
if(p)
{
gEASTLTest_AllocationCount--;
InternalFree(p);
}
}
void EASTLTest_SetGeneralAllocator()
{
EA::Allocator::SetGeneralAllocator(&EA::Allocator::EASTLTest_GetGeneralAllocator());
#ifdef EA_DEBUG
EA::Allocator::gpEAGeneralAllocatorDebug->SetDefaultDebugDataFlag(EA::Allocator::GeneralAllocatorDebug::kDebugDataIdGuard);
#endif
}