Quantum 3 3.1.0

Public Member Functions | List of all members
Photon.Deterministic.Native.Allocator Class Reference

Represents native memory allocations and is used in many places across the engine. More...

Inheritance diagram for Photon.Deterministic.Native.Allocator:
Photon.Deterministic.Native.PInvokeAllocator Photon.Deterministic.Native.LIBCAllocator Photon.Deterministic.Native.MSVCRTAllocator

Public Member Functions

void * Alloc (int count, [CallerFilePath] string callerFilePath=null, [CallerLineNumber] int callerLineNumber=0)
 Allocates memory from the unmanaged memory of the process. More...
 
void * Alloc (int count, int alignment, [CallerFilePath] string callerFilePath=null, [CallerLineNumber] int callerLineNumber=0)
 Allocates memory from the unmanaged memory of the process with a desired alignment. More...
 
T * Alloc< T > ([CallerFilePath] string callerFilePath=null, [CallerLineNumber] int callerLineNumber=0)
 Allocate native memory for a specific type. More...
 
void * AllocAndClear (int count, [CallerFilePath] string callerFilePath=null, [CallerLineNumber] int callerLineNumber=0)
 Allocate and clear native memory. More...
 
void * AllocAndClear (int count, int alignment, [CallerFilePath] string callerFilePath=null, [CallerLineNumber] int callerLineNumber=0)
 Allocate and clear native memory. More...
 
T * AllocAndClear< T > ([CallerFilePath] string callerFilePath=null, [CallerLineNumber] int callerLineNumber=0)
 Allocate and clear native memory for a specific type. More...
 
void Clear (void *dest, int count)
 Writes the desired number zeroed bytes to the specified memory location. More...
 
void Dispose ()
 Disposes the allocator and logs memory leaks in debug mode. More...
 
void * Expand (void *buffer, int currentSize, int newSize, [CallerFilePath] string callerFilePath=null, [CallerLineNumber] int callerLineNumber=0)
 Expands the allocated memory to a new size by copying the old contents and freeing the old memory. More...
 
T * ExpandArray< T > (T *buffer, int currentSize, int newSize, [CallerFilePath] string callerFilePath=null, [CallerLineNumber] int callerLineNumber=0)
 Expands the allocated memory of the array of the type to a new size by copying the old contents and freeing the old memory. More...
 
void Free (void *ptr)
 Frees memory previously allocated by this allocator. More...
 

Detailed Description

Represents native memory allocations and is used in many places across the engine.

Member Function Documentation

◆ Dispose()

void Photon.Deterministic.Native.Allocator.Dispose ( )
inline

Disposes the allocator and logs memory leaks in debug mode.

◆ Free()

void Photon.Deterministic.Native.Allocator.Free ( void *  ptr)
inline

Frees memory previously allocated by this allocator.

Parameters
ptrPointer to memory allocated with Alloc.

◆ Alloc() [1/2]

void* Photon.Deterministic.Native.Allocator.Alloc ( int  count,
[CallerFilePath] string  callerFilePath = null,
[CallerLineNumber] int  callerLineNumber = 0 
)
inline

Allocates memory from the unmanaged memory of the process.

Parameters
countThe required number of bytes in memory.
callerFilePath
callerLineNumber
Returns
A pointer to the newly allocated memory. This memory must be released using the Free method.

◆ Alloc() [2/2]

void* Photon.Deterministic.Native.Allocator.Alloc ( int  count,
int  alignment,
[CallerFilePath] string  callerFilePath = null,
[CallerLineNumber] int  callerLineNumber = 0 
)
inline

Allocates memory from the unmanaged memory of the process with a desired alignment.

Parameters
countThe required number of bytes in memory.
alignmentThe byte alignment.
callerFilePath
callerLineNumber
Returns
A pointer to the newly allocated memory. This memory must be released using the Free method.

◆ Clear()

void Photon.Deterministic.Native.Allocator.Clear ( void *  dest,
int  count 
)
inline

Writes the desired number zeroed bytes to the specified memory location.

Parameters
destThe destination memory.
countThe byte count.

◆ AllocAndClear() [1/2]

void* Photon.Deterministic.Native.Allocator.AllocAndClear ( int  count,
[CallerFilePath] string  callerFilePath = null,
[CallerLineNumber] int  callerLineNumber = 0 
)
inline

Allocate and clear native memory.

Parameters
countThe required number of bytes in memory.
Returns
A pointer to the newly allocated memory. This memory must be released using the Free method.

◆ AllocAndClear() [2/2]

void* Photon.Deterministic.Native.Allocator.AllocAndClear ( int  count,
int  alignment,
[CallerFilePath] string  callerFilePath = null,
[CallerLineNumber] int  callerLineNumber = 0 
)
inline

Allocate and clear native memory.

Parameters
countThe required number of bytes in memory.
alignmentThe byte alignment.
Returns
A pointer to the newly allocated memory. This memory must be released using the Free method.

◆ AllocAndClear< T >()

T* Photon.Deterministic.Native.Allocator.AllocAndClear< T > ( [CallerFilePath] string  callerFilePath = null,
[CallerLineNumber] int  callerLineNumber = 0 
)
inline

Allocate and clear native memory for a specific type.

Returns
A pointer to the newly allocated memory. This memory must be released using the Free method.
Type Constraints
T :unmanaged 

◆ Alloc< T >()

T* Photon.Deterministic.Native.Allocator.Alloc< T > ( [CallerFilePath] string  callerFilePath = null,
[CallerLineNumber] int  callerLineNumber = 0 
)
inline

Allocate native memory for a specific type.

Returns
A pointer to the newly allocated memory. This memory must be released using the Free method.
Type Constraints
T :unmanaged 

◆ Expand()

void* Photon.Deterministic.Native.Allocator.Expand ( void *  buffer,
int  currentSize,
int  newSize,
[CallerFilePath] string  callerFilePath = null,
[CallerLineNumber] int  callerLineNumber = 0 
)
inline

Expands the allocated memory to a new size by copying the old contents and freeing the old memory.

Parameters
bufferThe allocated memory.
currentSizeThe current size.
newSizeThe new size.
Returns
A pointer to the newly allocated memory. This memory must be released using the Free method.

◆ ExpandArray< T >()

T* Photon.Deterministic.Native.Allocator.ExpandArray< T > ( T *  buffer,
int  currentSize,
int  newSize,
[CallerFilePath] string  callerFilePath = null,
[CallerLineNumber] int  callerLineNumber = 0 
)
inline

Expands the allocated memory of the array of the type to a new size by copying the old contents and freeing the old memory.

Template Parameters
TThe data type.
Parameters
bufferThe allocated memory.
currentSizeThe current size.
newSizeThe new size.
Returns
A pointer to the newly allocated memory. This memory must be released using the Free method.
Type Constraints
T :unmanaged