namespace Misaki.HighPerformance.LowLevel.Contracts; /// /// A structure that encapsulates function pointers for memory allocation operations. /// public unsafe readonly struct AllocationHandle { /// /// Gets a pointer to the allocator instance associated with this allocation handle. /// public void* Allocator { get; } /// /// Gets a function pointer for allocating memory. /// public AllocFunc Alloc { get; } /// /// Gets a function pointer for reallocating memory. /// public ReallocFunc Realloc { get; } /// /// Gets a function pointer for freeing allocated memory. /// public FreeFunc Free { get; } /// /// Initializes a new instance of the struct with the specified allocator and memory /// management functions. /// /// A pointer to the allocator instance used for memory management. /// The function used to allocate memory. /// The function used to reallocate memory. /// The function used to free allocated memory. public AllocationHandle(void* allocator, AllocFunc alloc, ReallocFunc realloc, FreeFunc free) { Allocator = allocator; Alloc = alloc; Realloc = realloc; Free = free; } } /// /// Represents an allocator interface for managing memory allocations. /// /// /// The allocator must be static or pined to a specific memory region. /// Otherwise the pointer of the allocator, , may become invalid and lead to undefined behavior. /// public unsafe interface IAllocator { /// /// Gets a reference to the allocation handle associated with this allocator. /// public ref AllocationHandle Handle { get; } }