Photon Quantum 3.0.0

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

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 Quantum.QuantumUnityNativeAllocator Photon.Deterministic.Native.LIBCAllocator Photon.Deterministic.Native.MSVCRTAllocator

Public Member Functions

abstract void * Alloc (int count)
 Allocates memory from the unmanaged memory of the process. More...
 
abstract void * Alloc (int count, int alignment)
 Allocates memory from the unmanaged memory of the process with a desired alignment. More...
 
T * Alloc< T > ()
 Allocate native memory for a specific type. More...
 
void * AllocAndClear (int count)
 Allocate and clear native memory. More...
 
void * AllocAndClear (int count, int alignment)
 Allocate and clear native memory. More...
 
T * AllocAndClear< T > ()
 Allocate and clear native memory for a specific type. More...
 
void Dispose ()
 Disposes the allocator and logs memory leaks in debug mode. More...
 
void * Expand (void *buffer, int currentSize, int newSize)
 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)
 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...
 
abstract void Free (void *ptr)
 Frees memory previously allocated by this allocator. More...
 
abstract AllocatorVTableManaged GetManagedVTable ()
 Create a allocation operation table to be passed into native parts of the engine. More...
 

Protected Member Functions

abstract void Clear (void *dest, int count)
 Writes the desired number zeroed bytes to the specified memory location. 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()

abstract void Photon.Deterministic.Native.Allocator.Free ( void *  ptr)
pure virtual

Frees memory previously allocated by this allocator.

Parameters
ptrPointer to memory allocated with Alloc.

Implemented in Quantum.QuantumUnityNativeAllocator, and Photon.Deterministic.Native.PInvokeAllocator.

◆ Alloc() [1/2]

abstract void* Photon.Deterministic.Native.Allocator.Alloc ( int  count)
pure virtual

Allocates memory from the unmanaged memory of the process.

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.

Implemented in Quantum.QuantumUnityNativeAllocator, and Photon.Deterministic.Native.PInvokeAllocator.

◆ Alloc() [2/2]

abstract void* Photon.Deterministic.Native.Allocator.Alloc ( int  count,
int  alignment 
)
pure virtual

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

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.

Implemented in Quantum.QuantumUnityNativeAllocator, and Photon.Deterministic.Native.PInvokeAllocator.

◆ Clear()

abstract void Photon.Deterministic.Native.Allocator.Clear ( void *  dest,
int  count 
)
protectedpure virtual

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

Parameters
destThe destination memory.
countThe byte count.

Implemented in Quantum.QuantumUnityNativeAllocator, Photon.Deterministic.Native.LIBCAllocator, and Photon.Deterministic.Native.MSVCRTAllocator.

◆ AllocAndClear() [1/2]

void* Photon.Deterministic.Native.Allocator.AllocAndClear ( int  count)
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 
)
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 >()

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 >()

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 
)
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 
)
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 

◆ GetManagedVTable()

abstract AllocatorVTableManaged Photon.Deterministic.Native.Allocator.GetManagedVTable ( )
pure virtual

Create a allocation operation table to be passed into native parts of the engine.

Returns
Allocator table.

Implemented in Quantum.QuantumUnityNativeAllocator, Photon.Deterministic.Native.LIBCAllocator, and Photon.Deterministic.Native.MSVCRTAllocator.