Updated the SegmentedPool to allow for zeroing of allocations and for returning a pointer to allocated memory to allow for use in unsafe structs
This commit is contained in:
21
UnmangedMMU/Handles/PersistentMemoryHandle.cs
Normal file
21
UnmangedMMU/Handles/PersistentMemoryHandle.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using UnmanagedMMU.Allocators;
|
||||
|
||||
namespace UnmanagedMMU.Handles
|
||||
{
|
||||
internal sealed unsafe class PersistentMemoryHandle<T> : MemoryHandleBase<T> where T : unmanaged
|
||||
{
|
||||
|
||||
public PersistentMemoryHandle(void* ptr, nuint byteLength, IUnmanagedMemoryOwner owner) : base(ptr, byteLength, owner)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnDispose()
|
||||
{
|
||||
if (Pointer != null)
|
||||
{
|
||||
GetOwner().Free(this);
|
||||
// No need to set _ptr = null here; MemoryHandleBase._disposed flag prevents double-free
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user