diff --git a/src/NativeAllocator.cs b/src/NativeAllocator.cs index 3a1dbb9..421d05d 100644 --- a/src/NativeAllocator.cs +++ b/src/NativeAllocator.cs @@ -1,19 +1,23 @@ -using System.Runtime.InteropServices; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; namespace SharpAllocators { public readonly unsafe struct NativeAllocator : IAllocator { + [MethodImpl(MethodImplOptions.AggressiveInlining)] public T* Allocate(long count) where T : unmanaged { - return (T*)NativeMemory.Alloc((nuint)count); + return (T*)NativeMemory.Alloc((nuint)(count * sizeof(T))); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Free(T* pointer) where T : unmanaged { NativeMemory.Free(pointer); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public T* Reallocate(T* pointer, long count) where T : unmanaged { return (T*)NativeMemory.Realloc(pointer, (nuint)count);