WIP: Removed internal header tracking for WorkspaceHeap. Modified Handles to track the alignment that the underlying memory was aligned to. Re-worked WorkspaceHeap to use lists rather than Stack
This commit is contained in:
@@ -41,18 +41,25 @@ namespace UnmanagedMMU.Handles
|
||||
/// </summary>
|
||||
private bool _disposed;
|
||||
|
||||
/// <summary>
|
||||
/// The alignment of the memory pointed to by <see cref="_ptr"/>
|
||||
/// </summary>
|
||||
private readonly nuint _alignment;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new <see cref="MemoryHandleBase{T}"/> instnace
|
||||
/// </summary>
|
||||
/// <param name="ptr">Pointer to the allocated unmanaged memory</param>
|
||||
/// <param name="byteLength">The size of the unallocated memory block in bytes</param>
|
||||
/// <param name="alignment">The alignment that the unmanged memory pointed to by <paramref name="ptr"/> </param>
|
||||
/// <param name="owner">The <see cref="IUnmanagedMemoryOwner"/> that owns the <see cref="MemoryHandleBase{T}"/> handle being created</param>
|
||||
protected MemoryHandleBase(void* ptr, nuint byteLength, IUnmanagedMemoryOwner owner)
|
||||
protected MemoryHandleBase(void* ptr, nuint byteLength, nuint alignment, IUnmanagedMemoryOwner owner)
|
||||
{
|
||||
// Defensive check
|
||||
Debug.Assert(ptr != null, message: "BUG CHECK: E_INVALID_MEMORY_HANDLE");
|
||||
_ptr = ptr;
|
||||
_bytelen = byteLength;
|
||||
_alignment = alignment;
|
||||
_owner = owner;
|
||||
}
|
||||
|
||||
@@ -64,6 +71,14 @@ namespace UnmanagedMMU.Handles
|
||||
get { return _ptr; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the memory alignment for the <see cref="MemoryHandleBase{T}"/>
|
||||
/// </summary>
|
||||
public virtual nuint Alignment
|
||||
{
|
||||
get { return _alignment; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the typed pointer to the unmanged memory block
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user