diff --git a/src/IAllocator.cs b/src/IAllocator.cs index e8c32a5..85f610a 100644 --- a/src/IAllocator.cs +++ b/src/IAllocator.cs @@ -5,7 +5,7 @@ namespace SharpAllocators; public unsafe interface IAllocator { - public T* Allocate(long count) where T : unmanaged; + public T* Allocate(nuint elementCount) where T : unmanaged; public void Free(T* pointer) where T : unmanaged; - public T* Reallocate(T* pointer, long count) where T : unmanaged; + public T* Reallocate(T* pointer, nuint elementCount) where T : unmanaged; } \ No newline at end of file diff --git a/src/NativeAllocator.cs b/src/NativeAllocator.cs index d58ab0f..fb2327d 100644 --- a/src/NativeAllocator.cs +++ b/src/NativeAllocator.cs @@ -9,9 +9,9 @@ namespace SharpAllocators; public readonly unsafe struct NativeAllocator : IAllocator { [MethodImpl(MethodImplOptions.AggressiveInlining)] - public T* Allocate(long count) where T : unmanaged + public T* Allocate(nuint elementCount) where T : unmanaged { - return (T*)NativeMemory.Alloc((nuint)(count * sizeof(T))); + return (T*)NativeMemory.Alloc(elementCount * (nuint)sizeof(T)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -21,8 +21,8 @@ public void Free(T* pointer) where T : unmanaged } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public T* Reallocate(T* pointer, long count) where T : unmanaged + public T* Reallocate(T* pointer, nuint elementCount) where T : unmanaged { - return (T*)NativeMemory.Realloc(pointer, (nuint)count); + return (T*)NativeMemory.Realloc(pointer, elementCount); } }