using System.Runtime.InteropServices; namespace UnmanagedMMU.Allocators { /// /// Wrapper class around and . /// internal sealed unsafe class DefaultUnmanagedAllocator : IUnmanagedAllocator { /// public void* Alloc(nuint size) { return NativeMemory.AlignedAlloc(size, 16); } /// public void* AllocAligned(nuint size, nuint alignment) { if (!((alignment & (alignment - 1)) == 0 && alignment > 0)) { throw new ArgumentException("Alignment must be a power of 2.", nameof(alignment)); } return NativeMemory.AlignedAlloc(size, alignment); } /// public void Free(void* ptr) { NativeMemory.Free(ptr); } /// public void FreeAligned(void* ptr, nuint alignment = 0) { NativeMemory.AlignedFree(ptr); } } }