Better handling when size is 0

This commit is contained in:
2026-05-10 21:48:35 +09:00
parent 4b9d93ec65
commit f4abe2036a
7 changed files with 37 additions and 6 deletions

View File

@@ -58,6 +58,11 @@ public readonly struct MemoryHandle : IDisposable, IEquatable<MemoryHandle>
public void Dispose()
{
if (!IsInvalid)
{
return;
}
AllocationManager.RemoveAllocation(this);
}

View File

@@ -42,6 +42,11 @@ public unsafe struct MemoryBlock : IDisposable
public MemoryBlock(nuint size, nuint alignment, AllocationHandle handle, AllocationOption allocationOption = AllocationOption.None)
{
if (size == 0)
{
return;
}
_buffer = handle.Alloc(size, alignment, allocationOption);
_size = size;
_alignment = alignment;