Table of Contents

Class BasicHeap

Namespace
Echo.Memory.Heap
Assembly
Echo.dll

Provides a basic implementation of a heap.

public class BasicHeap : IHeap, IMemorySpace
Inheritance
BasicHeap
Implements
Inherited Members

Constructors

BasicHeap(int)

Creates a new empty heap.

public BasicHeap(int size)

Parameters

size int

The maximum size of the heap.

Properties

AddressRange

Gets the range that this memory space spans.

public AddressRange AddressRange { get; }

Property Value

AddressRange

Methods

Allocate(uint, bool)

Allocates a chunk of uninitialized memory in the heap.

public long Allocate(uint size, bool initialize)

Parameters

size uint

The size of the chunk in bytes.

initialize bool

A value indicating whether the chunk of memory should be cleared out with zeroes.

Returns

long

The address of the allocated chunk.

Free(long)

Releases a chunk of memory in the heap.

public void Free(long address)

Parameters

address long

The address of the chunk to free.

GetAllocatedChunks()

Gets a collection of all chunk address ranges within the heap that are currently allocated.

public IEnumerable<AddressRange> GetAllocatedChunks()

Returns

IEnumerable<AddressRange>

The ranges.

GetChunkSize(long)

Gets the size of the chunk that was allocated at the provided address.

public uint GetChunkSize(long address)

Parameters

address long

The address of the chunk.

Returns

uint

The size in bytes.

GetChunkSpan(long)

Obtains a writable bit vector slice that spans the entire chunk at a provided address.

public BitVectorSpan GetChunkSpan(long address)

Parameters

address long

The address of the chunk

Returns

BitVectorSpan

The chunk slice.

IsValidAddress(long)

Gets a value indicating whether the provided address is a valid address, and can be used to read and/or write to.

public bool IsValidAddress(long address)

Parameters

address long

The address to query.

Returns

bool

true if the address was valid, false otherwise.

Read(long, BitVectorSpan)

Copies data at the provided address into the provided buffer.

public void Read(long address, BitVectorSpan buffer)

Parameters

address long

The address to start reading at.

buffer BitVectorSpan

The buffer to write into.

Rebase(long)

Relocates the memory to a new base address.

public void Rebase(long baseAddress)

Parameters

baseAddress long

The new base address.

Write(long, BitVectorSpan)

Writes the provided buffer of data at the provided address.

public void Write(long address, BitVectorSpan buffer)

Parameters

address long

The address to start writing at.

buffer BitVectorSpan

The data to write.

Write(long, ReadOnlySpan<byte>)

Writes the provided buffer of data at the provided address.

public void Write(long address, ReadOnlySpan<byte> buffer)

Parameters

address long

The address to start writing at.

buffer ReadOnlySpan<byte>

The data to write.