Skip to content

IBufferFactory Interface#

Implement this interface to provide custom memory allocation.

Syntax#

C#

public interface IBufferFactory

VB

Public Interface IBufferFactory

The IBufferFactory type exposes the following members.

Methods#

NameDescription
Public methodAllocateBuffer Allocates a buffer and provides additional context information.
Public methodFreeBuffer Frees a previously allocated buffer.
 

IBufferFactory.AllocateBuffer Method#

Allocates a buffer and provides additional context information.

Syntax#

C#

void AllocateBuffer(
    long bufferSize,
    ref Object createdPinnedObject,
    ref IntPtr createdPinnedBuffer,
    ref Object bufferUserData
)

VB

Sub AllocateBuffer ( 
    bufferSize As Long,
    ByRef createdPinnedObject As Object,
    ByRef createdPinnedBuffer As IntPtr,
    ByRef bufferUserData As Object
)

Parameters#

 

bufferSize
Type: System.Int64
The size of the buffer in bytes that has to be allocated.
createdPinnedObject
Type: System.Object
Underlying object (e.g., Array of bytes) that is used for providing createdPinnedBuffer. This object is provided when FreeBuffer() is called.
createdPinnedBuffer
Type: System.IntPtr
Return the pointer to the allocated and pinned buffer. This pointer is provided when FreeBuffer() is called.
bufferUserData
Type: System.Object
User data information that belongs to the buffer. This user data information is provided when FreeBuffer() is called. The value can be left unchanged if not needed.

Remarks#

Thread Safety: This method must be thread-safe.

Error Safety: Must throw an exception if the allocation fails.

IBufferFactory.FreeBuffer Method#

Frees a previously allocated buffer.

Syntax#

C#

void FreeBuffer(
    Object createdPinnedObject,
    IntPtr createdPinnedBuffer,
    Object bufferUserData
)

VB

Sub FreeBuffer ( 
    createdPinnedObject As Object,
    createdPinnedBuffer As IntPtr,
    bufferUserData As Object
)

Parameters#

 

createdPinnedObject
Type: System.Object
The pointer to the allocated object. Created by this factory.
createdPinnedBuffer
Type: System.IntPtr
The pointer to the allocated buffer. Created by this factory.
bufferUserData
Type: System.Object
User data information of the buffer returned by AllocateBuffer(Int64, Object, IntPtr, Object).

Remarks#

Thread Safety: This method must be thread-safe.

Error Safety: Must not throw exceptions.