Table of Contents

Interface IAllocator

Namespace
SharpPluginLoader.Core.Memory
Assembly
SharpPluginLoader.Core.dll

Describes an allocator that can allocate and free unmanaged memory.

public interface IAllocator

Methods

Allocate(nint)

Allocates a block of memory of the specified size.

void* Allocate(nint size)

Parameters

size nint

The size of the memory block to allocate.

Returns

void*

A pointer to the allocated memory block.

Allocate<TObj>(int)

Allocates count instances of TObj.

TObj* Allocate<TObj>(int count) where TObj : unmanaged

Parameters

count int

The number of instances to allocate.

Returns

TObj*

A pointer to the allocated memory block.

Type Parameters

TObj

The type of object to allocate.

Free(void*)

Frees a previously allocated memory block.

void Free(void* ptr)

Parameters

ptr void*

The pointer to the memory block to free.