Badminton-Scoreboard/Libraries/libil2cpp/include/utils/New.h

35 lines
805 B
C
Raw Permalink Normal View History

2023-10-08 02:24:48 +00:00
#pragma once
#include "il2cpp-config.h"
#if IL2CPP_TARGET_WINDOWS || IL2CPP_TARGET_XBOXONE
#include <malloc.h>
#else
#include <stdlib.h>
#endif
#include <new>
inline void* operator new(size_t size, int alignment)
{
void* result = NULL;
#if IL2CPP_TARGET_WINDOWS || IL2CPP_TARGET_XBOXONE
result = _aligned_malloc(size, alignment);
#elif IL2CPP_TARGET_ANDROID || IL2CPP_TARGET_PSP2
result = memalign(alignment, size);
#else
if (posix_memalign(&result, size, alignment))
result = NULL;
#endif
if (!result)
throw std::bad_alloc();
return result;
}
#if IL2CPP_TARGET_WINDOWS || IL2CPP_TARGET_XBOXONE // Visual C++ warns if new is overridden but delete is not.
inline void operator delete(void* ptr, int alignment) throw ()
{
free(ptr);
}
#endif