Photon Fusion 2.0.4

Static Public Member Functions | Static Public Attributes | List of all members
Native Class Reference

Native Memory Allocator More...

Static Public Member Functions

static void * AlignPointer (void *pointer, int alignment)
 Aligns a pointer to a specified alignment. More...
 
static void ArrayClear< T > (T *ptr, int size)
 Clears a range of elements in an array by setting them to zero. More...
 
static int ArrayCompare< T > (T *ptr1, T *ptr2, int size)
 Compares two arrays for equality. More...
 
static void ArrayCopy (void *source, int sourceIndex, void *destination, int destinationIndex, int count, int elementStride)
 Copies a range of elements from one array to another. More...
 
static int CopyFromArray< T > (void *destination, T[] source)
 Copies elements from a managed array to an unmanaged memory location. More...
 
static int CopyToArray< T > (T[] destination, void *source)
 Copies elements from an unmanaged memory location to a managed array. More...
 
static T * DoubleArray< T > (T *array, int currentLength)
 Doubles the size of an array by expanding it to twice its current length. More...
 
static T ** DoublePtrArray< T > (T **array, int currentLength)
 Doubles the size of an array of pointers by expanding it to twice its current length. More...
 
static T Empty< T > ()
 Returns an empty instance of the specified unmanaged type. More...
 
static void * Expand (void *buffer, int currentSize, int newSize)
 Expands a buffer to a new specified size. More...
 
static T * ExpandArray< T > (T *array, int currentLength, int newLength)
 Expands an array to a new specified length. More...
 
static T ** ExpandPtrArray< T > (T **array, int currentLength, int newLength)
 Expands an array of pointers to a new specified length. More...
 
static void Free (void *memory)
 Frees a block of memory. More...
 
static int GetAlignment (int stride)
 Gets the alignment of the specified stride. More...
 
static int GetAlignment< T > ()
 Gets the alignment of the specified unmanaged type. More...
 
static int GetFieldOffset (System.Reflection.FieldInfo fi)
 Gets the offset of the specified field. More...
 
static int GetLengthPrefixedUTF8ByteCount (string str)
 Gets the byte count of a UTF-8 encoded string with a length prefix. More...
 
static int GetMaxAlignment (int a, int b)
 Gets the maximum alignment of two given strides. More...
 
static int GetMaxAlignment (int a, int b, int c)
 Gets the maximum alignment of three given strides. More...
 
static int GetMaxAlignment (int a, int b, int c, int d)
 Gets the maximum alignment of four given strides. More...
 
static int GetMaxAlignment (int a, int b, int c, int d, int e)
 Gets the maximum alignment of five given strides. More...
 
static bool IsAligned (int stride, int alignment)
 Checks if a stride is aligned to a specified alignment. More...
 
static bool IsPointerAligned (void *pointer, int alignment)
 Checks if a pointer is aligned to a specified alignment. More...
 
static void * Malloc (int size)
 Allocates a block of memory. More...
 
static T * Malloc< T > ()
 Allocates a block of memory for a specified type. More...
 
static void * MallocAndClear (int size)
 Allocates and clears a block of memory. More...
 
static T * MallocAndClear< T > ()
 Allocates and clears a block of memory for a specified type. More...
 
static void * MallocAndClearArray (int stride, int length)
 Allocates and clears an array of memory blocks. More...
 
static T * MallocAndClearArray< T > (int length)
 Allocates and clears an array of memory blocks for a specified type. More...
 
static T * MallocAndClearArrayMin1< T > (int length)
 Allocates and clears an array of memory blocks for a specified type, ensuring a minimum length of 1. More...
 
static int MallocAndClearBlock (int size0, int size1, int size2, int size3, int size4, int size5, int size6, int size7, int size8, int size9, int size10, int size11, out void *ptr0, out void *ptr1, out void *ptr2, out void *ptr3, out void *ptr4, out void *ptr5, out void *ptr6, out void *ptr7, out void *ptr8, out void *ptr9, out void *ptr10, out void *ptr11, int alignment=ALIGNMENT)
 Allocates a block of memory and clears it. More...
 
static int MallocAndClearBlock (int size0, int size1, int size2, int size3, int size4, int size5, int size6, int size7, int size8, int size9, int size10, out void *ptr0, out void *ptr1, out void *ptr2, out void *ptr3, out void *ptr4, out void *ptr5, out void *ptr6, out void *ptr7, out void *ptr8, out void *ptr9, out void *ptr10, int alignment=ALIGNMENT)
 Allocates a block of memory and clears it. More...
 
static int MallocAndClearBlock (int size0, int size1, int size2, int size3, int size4, int size5, int size6, int size7, int size8, int size9, out void *ptr0, out void *ptr1, out void *ptr2, out void *ptr3, out void *ptr4, out void *ptr5, out void *ptr6, out void *ptr7, out void *ptr8, out void *ptr9, int alignment=ALIGNMENT)
 Allocates a block of memory and clears it. More...
 
static int MallocAndClearBlock (int size0, int size1, int size2, int size3, int size4, int size5, int size6, int size7, int size8, out void *ptr0, out void *ptr1, out void *ptr2, out void *ptr3, out void *ptr4, out void *ptr5, out void *ptr6, out void *ptr7, out void *ptr8, int alignment=ALIGNMENT)
 Allocates a block of memory and clears it. More...
 
static int MallocAndClearBlock (int size0, int size1, int size2, int size3, int size4, int size5, int size6, int size7, out void *ptr0, out void *ptr1, out void *ptr2, out void *ptr3, out void *ptr4, out void *ptr5, out void *ptr6, out void *ptr7, int alignment=ALIGNMENT)
 Allocates a block of memory and clears it. More...
 
static int MallocAndClearBlock (int size0, int size1, int size2, int size3, int size4, int size5, int size6, out void *ptr0, out void *ptr1, out void *ptr2, out void *ptr3, out void *ptr4, out void *ptr5, out void *ptr6, int alignment=ALIGNMENT)
 Allocates a block of memory and clears it. More...
 
static int MallocAndClearBlock (int size0, int size1, int size2, int size3, int size4, int size5, out void *ptr0, out void *ptr1, out void *ptr2, out void *ptr3, out void *ptr4, out void *ptr5, int alignment=ALIGNMENT)
 Allocates a block of memory and clears it. More...
 
static int MallocAndClearBlock (int size0, int size1, int size2, int size3, int size4, out void *ptr0, out void *ptr1, out void *ptr2, out void *ptr3, out void *ptr4, int alignment=ALIGNMENT)
 Allocates a block of memory and clears it. More...
 
static int MallocAndClearBlock (int size0, int size1, int size2, int size3, out void *ptr0, out void *ptr1, out void *ptr2, out void *ptr3, int alignment=ALIGNMENT)
 Allocates a block of memory and clears it. More...
 
static int MallocAndClearBlock (int size0, int size1, int size2, out void *ptr0, out void *ptr1, out void *ptr2, int alignment=ALIGNMENT)
 Allocates a block of memory and clears it. More...
 
static int MallocAndClearBlock (int size0, int size1, out void *ptr0, out void *ptr1, int alignment=ALIGNMENT)
 Allocates a block of memory and clears it. More...
 
static T ** MallocAndClearPtrArray< T > (int length)
 Allocates and clears an array of pointers for a specified type. More...
 
static T ** MallocAndClearPtrArrayMin1< T > (int length)
 Allocates and clears an array of pointers for a specified type, ensuring a minimum length of 1. More...
 
static void MemClear (void *ptr, int size)
 Clears a block of memory by setting it to zero. More...
 
static int MemCmp (void *ptr1, void *ptr2, int size)
 Compares two blocks of memory. More...
 
static void MemCpy (void *destination, void *source, int size)
 Copies a block of memory from the source to the destination. More...
 
static void MemCpyFast (void *d, void *s, int size)
 Copies memory quickly for specific sizes. More...
 
static void MemMove (void *destination, void *source, int size)
 Moves a block of memory from the source to the destination. More...
 
static void PrintAllocatedButNotFreed ()
 
static int ReadLengthPrefixedUTF8 (void *source, out string result)
 Reads a length-prefixed UTF-8 encoded string from a memory location. More...
 
static unsafe byte * ReferenceToPointer< T > (ref T obj)
 Converts a reference to an unmanaged type to a pointer. More...
 
static int RoundBitsUpTo32 (int bits)
 Rounds the given number of bits up to the nearest multiple of 32. More...
 
static int RoundBitsUpTo64 (int bits)
 Rounds the given number of bits up to the nearest multiple of 64. More...
 
static int RoundToAlignment (int stride, int alignment)
 Rounds a stride to a specified alignment. More...
 
static long RoundToAlignment (long stride, int alignment)
 Rounds a stride to a specified alignment. More...
 
static int RoundToMaxAlignment (int stride)
 Rounds a stride to the maximum alignment. More...
 
static int SizeOf (Type t)
 Gets the size of the specified type. More...
 
static int WordCount (int stride, int wordSize)
 Calculates the word count for a given stride and word size. More...
 
static int WriteLengthPrefixedUTF8 (void *destination, string str)
 Writes a length-prefixed UTF-8 encoded string to a memory location. More...
 

Static Public Attributes

const int ALIGNMENT = 8
 The alignment size in bytes. More...
 
const int CACHE_LINE_SIZE = 64
 The size of the cache line in bytes. More...
 

Detailed Description

Native Memory Allocator

Member Function Documentation

◆ AlignPointer()

static void* AlignPointer ( void *  pointer,
int  alignment 
)
static

Aligns a pointer to a specified alignment.

Parameters
pointerThe pointer to align.
alignmentThe alignment to apply.
Returns
The aligned pointer.

◆ ArrayClear< T >()

static void ArrayClear< T > ( T *  ptr,
int  size 
)
static

Clears a range of elements in an array by setting them to zero.

Template Parameters
TThe type of the elements in the array.
Parameters
ptrThe pointer to the array.
sizeThe number of elements to clear.
Type Constraints
T :unmanaged 

◆ ArrayCompare< T >()

static int ArrayCompare< T > ( T *  ptr1,
T *  ptr2,
int  size 
)
static

Compares two arrays for equality.

Template Parameters
TThe type of the elements in the arrays.
Parameters
ptr1The pointer to the first array.
ptr2The pointer to the second array.
sizeThe number of elements to compare.
Returns
An integer that indicates the relative order of the arrays being compared.
Type Constraints
T :unmanaged 

◆ ArrayCopy()

static void ArrayCopy ( void *  source,
int  sourceIndex,
void *  destination,
int  destinationIndex,
int  count,
int  elementStride 
)
static

Copies a range of elements from one array to another.

Parameters
sourceThe source array pointer.
sourceIndexThe zero-based index in the source array at which copying begins.
destinationThe destination array pointer.
destinationIndexThe zero-based index in the destination array at which storing begins.
countThe number of elements to copy.
elementStrideThe size of each element in bytes.

◆ CopyFromArray< T >()

static int CopyFromArray< T > ( void *  destination,
T[]  source 
)
static

Copies elements from a managed array to an unmanaged memory location.

Template Parameters
TThe type of the elements in the array.
Parameters
destinationThe destination pointer.
sourceThe source array.
Returns
The number of bytes copied.
Type Constraints
T :unmanaged 

◆ CopyToArray< T >()

static int CopyToArray< T > ( T[]  destination,
void *  source 
)
static

Copies elements from an unmanaged memory location to a managed array.

Template Parameters
TThe type of the elements in the array.
Parameters
destinationThe destination array.
sourceThe source pointer.
Returns
The number of bytes copied.
Type Constraints
T :unmanaged 

◆ DoubleArray< T >()

static T* DoubleArray< T > ( T *  array,
int  currentLength 
)
static

Doubles the size of an array by expanding it to twice its current length.

Template Parameters
TThe type of the elements in the array.
Parameters
arrayThe pointer to the array to double.
currentLengthThe current length of the array.
Returns
A pointer to the new array with doubled size.
Type Constraints
T :unmanaged 

◆ DoublePtrArray< T >()

static T** DoublePtrArray< T > ( T **  array,
int  currentLength 
)
static

Doubles the size of an array of pointers by expanding it to twice its current length.

Template Parameters
TThe type of the elements in the array.
Parameters
arrayThe pointer to the array of pointers to double.
currentLengthThe current length of the array.
Returns
A pointer to the new array of pointers with doubled size.
Type Constraints
T :unmanaged 

◆ Empty< T >()

static T Empty< T > ( )
static

Returns an empty instance of the specified unmanaged type.

Template Parameters
TThe type of the instance to return.
Returns
An empty instance of the specified type.
Type Constraints
T :unmanaged 

◆ Expand()

static void* Expand ( void *  buffer,
int  currentSize,
int  newSize 
)
static

Expands a buffer to a new specified size.

Parameters
bufferThe pointer to the buffer to expand.
currentSizeThe current size of the buffer.
newSizeThe new size of the buffer.
Returns
A pointer to the new expanded buffer.

◆ ExpandArray< T >()

static T* ExpandArray< T > ( T *  array,
int  currentLength,
int  newLength 
)
static

Expands an array to a new specified length.

Template Parameters
TThe type of the elements in the array.
Parameters
arrayThe pointer to the array to expand.
currentLengthThe current length of the array.
newLengthThe new length of the array.
Returns
A pointer to the new expanded array.
Type Constraints
T :unmanaged 

◆ ExpandPtrArray< T >()

static T** ExpandPtrArray< T > ( T **  array,
int  currentLength,
int  newLength 
)
static

Expands an array of pointers to a new specified length.

Template Parameters
TThe type of the elements in the array.
Parameters
arrayThe pointer to the array of pointers to expand.
currentLengthThe current length of the array.
newLengthThe new length of the array.
Returns
A pointer to the new expanded array of pointers.
Type Constraints
T :unmanaged 

◆ Free()

static void Free ( void *  memory)
static

Frees a block of memory.

Parameters
memoryThe pointer to the memory block to free.

◆ GetAlignment()

static int GetAlignment ( int  stride)
static

Gets the alignment of the specified stride.

Parameters
strideThe stride to get the alignment of.
Returns
The alignment of the specified stride.

◆ GetAlignment< T >()

static int GetAlignment< T > ( )
static

Gets the alignment of the specified unmanaged type.

Template Parameters
TThe type to get the alignment of.
Returns
The alignment of the specified type.
Type Constraints
T :unmanaged 

◆ GetFieldOffset()

static int GetFieldOffset ( System.Reflection.FieldInfo  fi)
static

Gets the offset of the specified field.

Parameters
fiThe field information.
Returns
The offset of the specified field in bytes.

◆ GetLengthPrefixedUTF8ByteCount()

static int GetLengthPrefixedUTF8ByteCount ( string  str)
static

Gets the byte count of a UTF-8 encoded string with a length prefix.

Parameters
strThe string to encode.
Returns
The byte count of the encoded string with the length prefix.

◆ GetMaxAlignment() [1/4]

static int GetMaxAlignment ( int  a,
int  b 
)
static

Gets the maximum alignment of two given strides.

Parameters
aThe first stride.
bThe second stride.
Returns
The maximum alignment of the two strides.

◆ GetMaxAlignment() [2/4]

static int GetMaxAlignment ( int  a,
int  b,
int  c 
)
static

Gets the maximum alignment of three given strides.

Parameters
aThe first stride.
bThe second stride.
cThe third stride.
Returns
The maximum alignment of the three strides.

◆ GetMaxAlignment() [3/4]

static int GetMaxAlignment ( int  a,
int  b,
int  c,
int  d 
)
static

Gets the maximum alignment of four given strides.

Parameters
aThe first stride.
bThe second stride.
cThe third stride.
dThe fourth stride.
Returns
The maximum alignment of the four strides.

◆ GetMaxAlignment() [4/4]

static int GetMaxAlignment ( int  a,
int  b,
int  c,
int  d,
int  e 
)
static

Gets the maximum alignment of five given strides.

Parameters
aThe first stride.
bThe second stride.
cThe third stride.
dThe fourth stride.
eThe fifth stride.
Returns
The maximum alignment of the five strides.

◆ IsAligned()

static bool IsAligned ( int  stride,
int  alignment 
)
static

Checks if a stride is aligned to a specified alignment.

Parameters
strideThe stride to check.
alignmentThe alignment to check against.
Returns
True if the stride is aligned, otherwise false.

◆ IsPointerAligned()

static bool IsPointerAligned ( void *  pointer,
int  alignment 
)
static

Checks if a pointer is aligned to a specified alignment.

Parameters
pointerThe pointer to check.
alignmentThe alignment to check against.
Returns
True if the pointer is aligned, otherwise false.

◆ Malloc()

static void* Malloc ( int  size)
static

Allocates a block of memory.

Parameters
sizeThe number of bytes to allocate.
Returns
A pointer to the allocated memory block.
Exceptions
ExceptionThrown when the size is less than or equal to zero or exceeds the maximum allowed size.

◆ Malloc< T >()

static T* Malloc< T > ( )
static

Allocates a block of memory for a specified type.

Template Parameters
TThe type of the memory block to allocate.
Returns
A pointer to the allocated memory block.
Type Constraints
T :unmanaged 

◆ MallocAndClear()

static void* MallocAndClear ( int  size)
static

Allocates and clears a block of memory.

Parameters
sizeThe number of bytes to allocate and clear.
Returns
A pointer to the allocated and cleared memory block.

◆ MallocAndClear< T >()

static T* MallocAndClear< T > ( )
static

Allocates and clears a block of memory for a specified type.

Template Parameters
TThe type of the memory block to allocate and clear.
Returns
A pointer to the allocated and cleared memory block.
Type Constraints
T :unmanaged 

◆ MallocAndClearArray()

static void* MallocAndClearArray ( int  stride,
int  length 
)
static

Allocates and clears an array of memory blocks.

Parameters
strideThe size of each element in the array.
lengthThe number of elements in the array.
Returns
A pointer to the allocated and cleared array of memory blocks.

◆ MallocAndClearArray< T >()

static T* MallocAndClearArray< T > ( int  length)
static

Allocates and clears an array of memory blocks for a specified type.

Template Parameters
TThe type of the elements in the array.
Parameters
lengthThe number of elements in the array.
Returns
A pointer to the allocated and cleared array of memory blocks.
Type Constraints
T :unmanaged 

◆ MallocAndClearArrayMin1< T >()

static T* MallocAndClearArrayMin1< T > ( int  length)
static

Allocates and clears an array of memory blocks for a specified type, ensuring a minimum length of 1.

Template Parameters
TThe type of the elements in the array.
Parameters
lengthThe number of elements in the array.
Returns
A pointer to the allocated and cleared array of memory blocks.
Type Constraints
T :unmanaged 

◆ MallocAndClearBlock() [1/11]

static int MallocAndClearBlock ( int  size0,
int  size1,
int  size2,
int  size3,
int  size4,
int  size5,
int  size6,
int  size7,
int  size8,
int  size9,
int  size10,
int  size11,
out void *  ptr0,
out void *  ptr1,
out void *  ptr2,
out void *  ptr3,
out void *  ptr4,
out void *  ptr5,
out void *  ptr6,
out void *  ptr7,
out void *  ptr8,
out void *  ptr9,
out void *  ptr10,
out void *  ptr11,
int  alignment = ALIGNMENT 
)
static

Allocates a block of memory and clears it.

◆ MallocAndClearBlock() [2/11]

static int MallocAndClearBlock ( int  size0,
int  size1,
int  size2,
int  size3,
int  size4,
int  size5,
int  size6,
int  size7,
int  size8,
int  size9,
int  size10,
out void *  ptr0,
out void *  ptr1,
out void *  ptr2,
out void *  ptr3,
out void *  ptr4,
out void *  ptr5,
out void *  ptr6,
out void *  ptr7,
out void *  ptr8,
out void *  ptr9,
out void *  ptr10,
int  alignment = ALIGNMENT 
)
static

Allocates a block of memory and clears it.

◆ MallocAndClearBlock() [3/11]

static int MallocAndClearBlock ( int  size0,
int  size1,
int  size2,
int  size3,
int  size4,
int  size5,
int  size6,
int  size7,
int  size8,
int  size9,
out void *  ptr0,
out void *  ptr1,
out void *  ptr2,
out void *  ptr3,
out void *  ptr4,
out void *  ptr5,
out void *  ptr6,
out void *  ptr7,
out void *  ptr8,
out void *  ptr9,
int  alignment = ALIGNMENT 
)
static

Allocates a block of memory and clears it.

◆ MallocAndClearBlock() [4/11]

static int MallocAndClearBlock ( int  size0,
int  size1,
int  size2,
int  size3,
int  size4,
int  size5,
int  size6,
int  size7,
int  size8,
out void *  ptr0,
out void *  ptr1,
out void *  ptr2,
out void *  ptr3,
out void *  ptr4,
out void *  ptr5,
out void *  ptr6,
out void *  ptr7,
out void *  ptr8,
int  alignment = ALIGNMENT 
)
static

Allocates a block of memory and clears it.

◆ MallocAndClearBlock() [5/11]

static int MallocAndClearBlock ( int  size0,
int  size1,
int  size2,
int  size3,
int  size4,
int  size5,
int  size6,
int  size7,
out void *  ptr0,
out void *  ptr1,
out void *  ptr2,
out void *  ptr3,
out void *  ptr4,
out void *  ptr5,
out void *  ptr6,
out void *  ptr7,
int  alignment = ALIGNMENT 
)
static

Allocates a block of memory and clears it.

◆ MallocAndClearBlock() [6/11]

static int MallocAndClearBlock ( int  size0,
int  size1,
int  size2,
int  size3,
int  size4,
int  size5,
int  size6,
out void *  ptr0,
out void *  ptr1,
out void *  ptr2,
out void *  ptr3,
out void *  ptr4,
out void *  ptr5,
out void *  ptr6,
int  alignment = ALIGNMENT 
)
static

Allocates a block of memory and clears it.

◆ MallocAndClearBlock() [7/11]

static int MallocAndClearBlock ( int  size0,
int  size1,
int  size2,
int  size3,
int  size4,
int  size5,
out void *  ptr0,
out void *  ptr1,
out void *  ptr2,
out void *  ptr3,
out void *  ptr4,
out void *  ptr5,
int  alignment = ALIGNMENT 
)
static

Allocates a block of memory and clears it.

◆ MallocAndClearBlock() [8/11]

static int MallocAndClearBlock ( int  size0,
int  size1,
int  size2,
int  size3,
int  size4,
out void *  ptr0,
out void *  ptr1,
out void *  ptr2,
out void *  ptr3,
out void *  ptr4,
int  alignment = ALIGNMENT 
)
static

Allocates a block of memory and clears it.

◆ MallocAndClearBlock() [9/11]

static int MallocAndClearBlock ( int  size0,
int  size1,
int  size2,
int  size3,
out void *  ptr0,
out void *  ptr1,
out void *  ptr2,
out void *  ptr3,
int  alignment = ALIGNMENT 
)
static

Allocates a block of memory and clears it.

◆ MallocAndClearBlock() [10/11]

static int MallocAndClearBlock ( int  size0,
int  size1,
int  size2,
out void *  ptr0,
out void *  ptr1,
out void *  ptr2,
int  alignment = ALIGNMENT 
)
static

Allocates a block of memory and clears it.

◆ MallocAndClearBlock() [11/11]

static int MallocAndClearBlock ( int  size0,
int  size1,
out void *  ptr0,
out void *  ptr1,
int  alignment = ALIGNMENT 
)
static

Allocates a block of memory and clears it.

◆ MallocAndClearPtrArray< T >()

static T** MallocAndClearPtrArray< T > ( int  length)
static

Allocates and clears an array of pointers for a specified type.

Template Parameters
TThe type of the elements in the array.
Parameters
lengthThe number of elements in the array.
Returns
A pointer to the allocated and cleared array of pointers.
Type Constraints
T :unmanaged 

◆ MallocAndClearPtrArrayMin1< T >()

static T** MallocAndClearPtrArrayMin1< T > ( int  length)
static

Allocates and clears an array of pointers for a specified type, ensuring a minimum length of 1.

Template Parameters
TThe type of the elements in the array.
Parameters
lengthThe number of elements in the array.
Returns
A pointer to the allocated and cleared array of pointers.
Type Constraints
T :unmanaged 

◆ MemClear()

static void MemClear ( void *  ptr,
int  size 
)
static

Clears a block of memory by setting it to zero.

Parameters
ptrThe pointer to the memory block.
sizeThe number of bytes to clear.

◆ MemCmp()

static int MemCmp ( void *  ptr1,
void *  ptr2,
int  size 
)
static

Compares two blocks of memory.

Parameters
ptr1The first memory block pointer.
ptr2The second memory block pointer.
sizeThe number of bytes to compare.
Returns
An integer that indicates the relative order of the memory blocks being compared.

◆ MemCpy()

static void MemCpy ( void *  destination,
void *  source,
int  size 
)
static

Copies a block of memory from the source to the destination.

Parameters
destinationThe destination pointer.
sourceThe source pointer.
sizeThe number of bytes to copy.

◆ MemCpyFast()

static void MemCpyFast ( void *  d,
void *  s,
int  size 
)
static

Copies memory quickly for specific sizes.

Parameters
dThe destination pointer.
sThe source pointer.
sizeThe number of bytes to copy.

◆ MemMove()

static void MemMove ( void *  destination,
void *  source,
int  size 
)
static

Moves a block of memory from the source to the destination.

Parameters
destinationThe destination pointer.
sourceThe source pointer.
sizeThe number of bytes to move.

◆ ReadLengthPrefixedUTF8()

static int ReadLengthPrefixedUTF8 ( void *  source,
out string  result 
)
static

Reads a length-prefixed UTF-8 encoded string from a memory location.

Parameters
sourceThe source pointer.
resultThe resulting string.
Returns
The number of bytes read.

◆ ReferenceToPointer< T >()

static unsafe byte* ReferenceToPointer< T > ( ref T  obj)
static

Converts a reference to an unmanaged type to a pointer.

Template Parameters
TThe type of the object.
Parameters
objThe reference to the object.
Returns
A pointer to the object.
Type Constraints
T :unmanaged 

◆ RoundBitsUpTo32()

static int RoundBitsUpTo32 ( int  bits)
static

Rounds the given number of bits up to the nearest multiple of 32.

Parameters
bitsThe number of bits to round up.
Returns
The rounded number of bits.

◆ RoundBitsUpTo64()

static int RoundBitsUpTo64 ( int  bits)
static

Rounds the given number of bits up to the nearest multiple of 64.

Parameters
bitsThe number of bits to round up.
Returns
The rounded number of bits.

◆ RoundToAlignment() [1/2]

static int RoundToAlignment ( int  stride,
int  alignment 
)
static

Rounds a stride to a specified alignment.

Parameters
strideThe stride to round.
alignmentThe alignment to apply.
Returns
The rounded stride.
Exceptions
InvalidOperationExceptionThrown when the alignment is invalid.

◆ RoundToAlignment() [2/2]

static long RoundToAlignment ( long  stride,
int  alignment 
)
static

Rounds a stride to a specified alignment.

Parameters
strideThe stride to round.
alignmentThe alignment to apply.
Returns
The rounded stride.
Exceptions
InvalidOperationExceptionThrown when the alignment is invalid.

◆ RoundToMaxAlignment()

static int RoundToMaxAlignment ( int  stride)
static

Rounds a stride to the maximum alignment.

Parameters
strideThe stride to round.
Returns
The rounded stride.

◆ SizeOf()

static int SizeOf ( Type  t)
static

Gets the size of the specified type.

Parameters
tThe type to get the size of.
Returns
The size of the specified type in bytes.

◆ WordCount()

static int WordCount ( int  stride,
int  wordSize 
)
static

Calculates the word count for a given stride and word size.

Parameters
strideThe stride to calculate.
wordSizeThe size of each word.
Returns
The word count.

◆ WriteLengthPrefixedUTF8()

static int WriteLengthPrefixedUTF8 ( void *  destination,
string  str 
)
static

Writes a length-prefixed UTF-8 encoded string to a memory location.

Parameters
destinationThe destination pointer.
strThe string to encode and write.
Returns
The number of bytes written.

Member Data Documentation

◆ ALIGNMENT

const int ALIGNMENT = 8
static

The alignment size in bytes.

◆ CACHE_LINE_SIZE

const int CACHE_LINE_SIZE = 64
static

The size of the cache line in bytes.