Interface IBufferAllocator

Interface of a buffer allocator, customizing the allocation of the memory used by ImageBuffer objects.

Namespace: ic4
Assembly: ic4dotnet.dll
Syntax
public interface IBufferAllocator
Remarks

Objects of classes implementing this interface can be passed into multiple library functions:

Methods

Allocate(ulong, ulong, out IntPtr, out object)

Allocates the requested number of bytes of memory for an image buffer.

Declaration

bool Allocate(ulong bufferSize, ulong alignment, out IntPtr buffer, out object tag)

Parameters

Type Name Description
ulong bufferSize

The size of the memory buffer

ulong alignment

Requested alignment for the allocation.

IntPtr buffer

Output parameter receiving the memory address, filled by the function.

The memory address must be evenly divisible by alignment.

object tag

Output parameter receiving the reference to an object that is stored as part of the image buffer and passed to Free(IntPtr, object) when the memory is to be released.

Returns

Type Description
bool

true, if the allocation was performed successfully, otherwise false.

Free(IntPtr, object)

Frees a memory block that was previously allocated by a successful call of Allocate(ulong, ulong, out IntPtr, out object).

Declaration

void Free(IntPtr buffer, object tag)

Parameters

Type Name Description
IntPtr buffer

The memory address of the allocated buffer

object tag

The object that was returned through the tag parameter in the call of the allocation call.