Table of Contents

Class MtAllocator

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

Represents an instance of an MtAllocator, the default memory allocator for the game.

public class MtAllocator : MtObject, IAllocator
Inheritance
MtAllocator
Implements
Inherited Members

Constructors

MtAllocator()

public MtAllocator()

MtAllocator(nint)

public MtAllocator(nint instance)

Parameters

instance nint

Methods

Allocate(nint)

Allocates a block of memory of the specified size.

public void* Allocate(nint size)

Parameters

size nint

The size of the memory block to allocate.

Returns

void*

A pointer to the allocated memory block.

Remarks

Memory allocated with this method will always be aligned to 16 bytes.

Allocate(nint, int)

Allocates a block of memory of the specified size and alignment.

public void* Allocate(nint size, int alignment)

Parameters

size nint

The size of the memory block to allocate.

alignment int

The alignment of the memory block to allocate.

Returns

void*

A pointer to the allocated memory block.

Allocate<TObj>(int)

Allocates count instances of TObj.

public TObj* Allocate<TObj>(int count = 1) 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.

public void Free(void* ptr)

Parameters

ptr void*

The pointer to the memory block to free.