Fixed abug in Stack and VirtualStack
This commit is contained in:
@@ -142,16 +142,8 @@ public unsafe partial struct Stack : IMemoryAllocator<Stack, Stack.CreationOpts>
|
|||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void Free(void* ptr)
|
public readonly void Free(void* ptr)
|
||||||
{
|
{
|
||||||
if (ptr < _buffer && ptr >= _buffer + _size)
|
|
||||||
{
|
|
||||||
Debug.Fail("Attempting to free a pointer that is out of bounds of the current stack allocation.");
|
|
||||||
return; // Pointer is out of bounds, ignore
|
|
||||||
}
|
|
||||||
|
|
||||||
var offset = (nuint)((byte*)ptr - _buffer);
|
|
||||||
_offset = offset < _offset ? offset : _offset;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -162,16 +162,8 @@ public unsafe struct VirtualStack : IMemoryAllocator<VirtualStack, VirtualStack.
|
|||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void Free(void* ptr)
|
public readonly void Free(void* ptr)
|
||||||
{
|
{
|
||||||
if (ptr < _baseAddress && ptr >= _baseAddress + _committedSize)
|
|
||||||
{
|
|
||||||
Debug.Fail("Attempting to free a pointer that is out of bounds of the current stack allocation.");
|
|
||||||
return; // Pointer is out of bounds, ignore
|
|
||||||
}
|
|
||||||
|
|
||||||
var offset = (nuint)((byte*)ptr - _baseAddress);
|
|
||||||
_allocatedOffset = offset < _allocatedOffset ? offset : _allocatedOffset;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||||
<Authors>Misaki</Authors>
|
<Authors>Misaki</Authors>
|
||||||
<AssemblyVersion>1.6.8</AssemblyVersion>
|
<AssemblyVersion>1.6.9</AssemblyVersion>
|
||||||
<Version>$(AssemblyVersion)</Version>
|
<Version>$(AssemblyVersion)</Version>
|
||||||
<PackageProjectUrl>https://git.personalnas.com/Misaki/Misaki.HighPerformance.git</PackageProjectUrl>
|
<PackageProjectUrl>https://git.personalnas.com/Misaki/Misaki.HighPerformance.git</PackageProjectUrl>
|
||||||
<RepositoryUrl>https://git.personalnas.com/Misaki/Misaki.HighPerformance.git</RepositoryUrl>
|
<RepositoryUrl>https://git.personalnas.com/Misaki/Misaki.HighPerformance.git</RepositoryUrl>
|
||||||
|
|||||||
Reference in New Issue
Block a user