Prefer NativeMemory.AlignedAlloc over Marshal.Alloc*

This commit is contained in:
2022-12-26 14:29:32 +02:00
parent d966519d95
commit f12475ea99
2 changed files with 86 additions and 54 deletions

View File

@@ -129,12 +129,7 @@ void CoreCLR::RegisterNativeLibrary(const char* moduleName, const char* modulePa
void* CoreCLR::Allocate(int size)
{
#if PLATFORM_WINDOWS
void* ptr = CoTaskMemAlloc(size);
#else
void* ptr = malloc(size);
#endif
void* ptr = Platform::Allocate(size, 16);
#if COMPILE_WITH_PROFILER
Platform::OnMemoryAlloc(ptr, size);
#endif
@@ -146,9 +141,5 @@ void CoreCLR::Free(void* ptr)
#if COMPILE_WITH_PROFILER
Platform::OnMemoryFree(ptr);
#endif
#if PLATFORM_WINDOWS
CoTaskMemFree(ptr);
#else
free(ptr);
#endif
Platform::Free(ptr);
}