Add TLSF allocator and refactor allocation API

- Introduced TLSF allocator with thread-safe wrapper and integrated into AllocationManager.
- Extended AllocationManagerDesc for TLSF config; made properties settable.
- Refactored AllocationHandle to encapsulate function pointers and state, replacing direct field access with methods.
- Updated all memory-related structs to use new AllocationHandle API.
- Added ReplaceIfZeros utility to MemoryUtility.
- Improved IndexOfNullByte performance.
- Minor fix in MemoryLeakException output order.
- FreeList now uses a fixed 64KB refill budget.
- Bumped version to 1.6.21; removed MHP_ENABLE_STACKTRACE from Debug.
- Updated Program.cs to test TLSF allocator and manage allocation lifecycle.
This commit is contained in:
2026-05-05 22:13:58 +09:00
parent 627c1da928
commit d3e497c7d8
14 changed files with 303 additions and 114 deletions

View File

@@ -19,13 +19,7 @@ public unsafe struct MemoryPool<TAllocator, TOpts> : IDisposable
_pAllocator = (TAllocator*)Malloc((nuint)sizeof(TAllocator));
*_pAllocator = allocator;
_allocationHandle = new AllocationHandle
{
State = _pAllocator,
Alloc = &Allocate,
Realloc = &Reallocate,
Free = &Free
};
_allocationHandle = new AllocationHandle(_pAllocator, &Allocate, &Reallocate, &Free);
}
private static void* Allocate(void* pAllocator, nuint size, nuint alignment, AllocationOption allocationOption)