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
instancenint
Methods
Allocate(nint)
Allocates a block of memory of the specified size.
public void* Allocate(nint size)
Parameters
sizenintThe 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
sizenintThe size of the memory block to allocate.
alignmentintThe 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
countintThe number of instances to allocate.
Returns
- TObj*
A pointer to the allocated memory block.
Type Parameters
TObjThe type of object to allocate.
Free(void*)
Frees a previously allocated memory block.
public void Free(void* ptr)
Parameters
ptrvoid*The pointer to the memory block to free.