hlsf error is solving

This commit is contained in:
Youmu Liu
2025-11-28 18:18:08 +08:00
parent a3570bf20a
commit 0c90461d35
8 changed files with 253 additions and 281 deletions
@@ -39,9 +39,7 @@ namespace StgSharp.HighPerformance.Memory
// Bucket system field - directly in main allocator class
private BucketNode*[] _bucketHeads;
// Head of the position linked list (first Entry in memory order)
private Entry* _positionHead;
// _spareMemory is also the beginning position of allocator
private Entry* _spareMemory;
private readonly byte* m_Buffer;
private bool disposedValue;
@@ -63,8 +61,8 @@ namespace StgSharp.HighPerformance.Memory
_spareMemory = (Entry*)_entries.Allocate();
_spareMemory->State = EntryState.Spare;
_spareMemory->PreviousNear = null;
_spareMemory->NextNear = null;
_spareMemory->PreviousNear = _spareMemory;
_spareMemory->NextNear = _spareMemory;
_spareMemory->Position = (nuint)m_Buffer;
_spareMemory->Size = (uint)byteSize;
}
@@ -73,19 +71,19 @@ namespace StgSharp.HighPerformance.Memory
{
if (align < 16 || (align & (align - 1)) != 0) {
throw new ArgumentException(
"Alignment must be a power of two and at least 8 bytes.");
"Alignment must be a power of two and at least 16 bytes.");
}
_entries = SlabAllocator<Entry>.Create(64, SlabBufferLayout.Chunked);
m_Buffer = (byte*)NativeMemory.AlignedAlloc(byteSize, (nuint)align);
_align = align;
_size = byteSize;
_bucketHeads = new BucketNode*[levelSizeArray.Length * 3];
_bucketHeads = new BucketNode*[levelSizeArray.Length * 3 + 1];
_spareMemory = (Entry*)_entries.Allocate();
_spareMemory->State = EntryState.Empty;
_spareMemory->PreviousNear = null;
_spareMemory->NextNear = null;
_spareMemory->PreviousNear = _spareMemory;
_spareMemory->NextNear = _spareMemory;
_spareMemory->Position = (nuint)m_Buffer;
_spareMemory->Size = (uint)byteSize;
}