Added SegmentedPool
This commit is contained in:
16
UnmangedMMU/Allocators/DefaultUnmanagedAllocator.cs
Normal file
16
UnmangedMMU/Allocators/DefaultUnmanagedAllocator.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace UnmanagedMMU.Allocators
|
||||
{
|
||||
/// <summary>
|
||||
/// Wrapper class around <see cref="NativeMemory.Alloc(nuint)"/> and <see cref="NativeMemory.Free(void*)"/>.
|
||||
/// </summary>
|
||||
internal sealed unsafe class DefaultUnmanagedAllocator : IUnmanagedAllocator
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public void* Alloc(nuint size) => NativeMemory.Alloc(size);
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Free(void* ptr) => NativeMemory.Free(ptr);
|
||||
}
|
||||
}
|
||||
23
UnmangedMMU/Allocators/IUnmanagedAllocator.cs
Normal file
23
UnmangedMMU/Allocators/IUnmanagedAllocator.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
namespace UnmanagedMMU.Allocators
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface that defines an Unmanaged allocator
|
||||
/// </summary>
|
||||
internal unsafe interface IUnmanagedAllocator
|
||||
{
|
||||
/// <summary>
|
||||
/// Allocates an unmanaged memory block of the specified size.
|
||||
/// </summary>
|
||||
/// <param name="size">The number of bytes to allocate.</param>
|
||||
/// <returns>
|
||||
/// A pointer to the beginning of the allocated memory block,.
|
||||
/// </returns>
|
||||
void* Alloc(nuint size);
|
||||
|
||||
/// <summary>
|
||||
/// Frees a previously allocated unmanaged memory block.
|
||||
/// </summary>
|
||||
/// <param name="ptr">A pointer to the beginning of the memory block to free.</param>
|
||||
void Free(void* ptr);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user