Quantum 3 3.1.0

Static Public Member Functions | Static Public Attributes | List of all members
Quantum.QuantumUnsafe Class Reference

Utility methods for memory operations. More...

Static Public Member Functions

static void * Alloc (int size, int align=DefaultAlignment, [CallerFilePath] string callerFilePath=null, [CallerLineNumber] int callerLineNumber=0)
 Allocates a block of memory. The return address is 8-aligned. More...
 
static T * Alloc< T > (int align=DefaultAlignment, [CallerFilePath] string callerFilePath=null, [CallerLineNumber] int callerLineNumber=0)
 Allocates a block of memory. The return address is 8-aligned. More...
 
static void * AllocAndClear (int size, int align=DefaultAlignment, [CallerFilePath] string callerFilePath=null, [CallerLineNumber] int callerLineNumber=0)
 Allocates a block of memory. The memory is 0-initialized. The return address is 8-aligned. More...
 
static T * AllocAndClear< T > (int align=DefaultAlignment, [CallerFilePath] string callerFilePath=null, [CallerLineNumber] int callerLineNumber=0)
 Allocates a block of memory. The memory is 0-initialized. The return address is 8-aligned. More...
 
static void * AllocAndClearArray (int count, int elementSize, int align=DefaultAlignment, [CallerFilePath] string callerFilePath=null, [CallerLineNumber] int callerLineNumber=0)
 Allocates a block of memory. The memory is 0-initialized. The return address is 8-aligned. More...
 
static T * AllocAndClearArray< T > (int count, int align=DefaultAlignment, [CallerFilePath] string callerFilePath=null, [CallerLineNumber] int callerLineNumber=0)
 Allocates a block of memory. The memory is 0-initialized. The return address is 8-aligned. More...
 
static int AllocAndClearBlock (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 align=DefaultAlignment)
 Allocates a block of memory and clears it. More...
 
static int AllocAndClearBlock (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 align=DefaultAlignment)
 Allocates a block of memory and clears it. More...
 
static int AllocAndClearBlock (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 align=DefaultAlignment)
 Allocates a block of memory and clears it. More...
 
static int AllocAndClearBlock (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 align=DefaultAlignment)
 Allocates a block of memory and clears it. More...
 
static int AllocAndClearBlock (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 align=DefaultAlignment)
 Allocates a block of memory and clears it. More...
 
static int AllocAndClearBlock (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 align=DefaultAlignment)
 Allocates a block of memory and clears it. More...
 
static int AllocAndClearBlock (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 align=DefaultAlignment)
 Allocates a block of memory and clears it. More...
 
static int AllocAndClearBlock (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 align=DefaultAlignment)
 Allocates a block of memory and clears it. More...
 
static int AllocAndClearBlock (int size0, int size1, int size2, int size3, out void *ptr0, out void *ptr1, out void *ptr2, out void *ptr3, int align=DefaultAlignment)
 Allocates a block of memory and clears it. More...
 
static int AllocAndClearBlock (int size0, int size1, int size2, out void *ptr0, out void *ptr1, out void *ptr2, int align=DefaultAlignment)
 Allocates a block of memory and clears it. More...
 
static int AllocAndClearBlock (int size0, int size1, out void *ptr0, out void *ptr1, int align=DefaultAlignment)
 Allocates a block of memory and clears it. More...
 
static T ** AllocAndClearPtrArray< T > (int capacity, int align=DefaultAlignment, [CallerFilePath] string callerFilePath=null, [CallerLineNumber] int callerLineNumber=0)
 Allocates a block of memory. The memory is 0-initialized. The return address is 8-aligned. More...
 
static void * AllocInternal (int size, int align=DefaultAlignment)
 Allocates a block of memory. More...
 
static void Clear ([NotNull] void *ptr, int size)
 Clears a block of memory by setting it to zero. More...
 
static void Clear< T > (Span< T > span)
 Clears a block of memory by setting it to zero. More...
 
static int Compare ([NotNull] void *ptr1, [NotNull] void *ptr2, int size)
 Compares two blocks of memory. More...
 
static int Compare (nint ptr1, nint ptr2, nuint size)
 Compares two blocks of memory. More...
 
static void Copy ([NotNull] void *destination, [NotNull] void *source, int size)
 Copies a block of memory from the source to the destination. More...
 
static void Copy (nint destination, nint source, nuint size)
 Copies a block of memory from the source to the destination. More...
 
static void Copy< T > (Span< T > destination, ReadOnlySpan< T > source)
 Copy from source to destination, with CopyTo semantics: destination must be the same size or bigger than source. If source is smaller than destination the excess part of destination is not written to. More...
 
static void Copy< T > (Span< T > destination, T *source)
 Copies a block of memory from the source to the destination. More...
 
static void Copy< T > (T *destination, ReadOnlySpan< T > source)
 Copies a block of memory from the source to the destination. More...
 
static void CopyToExact< T > (Span< T > destination, ReadOnlySpan< T > source)
 Copy from source to destination, like CopyTo but source and destination must be the same size. More...
 
static void * Expand (void *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...
 
static 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...
 
static T ** ExpandPtrArray< 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...
 
static void Free (ref void *ptr)
 Frees ptr . If it is null, nothing will happen. More...
 
static void Free (void *ptr)
 Frees ptr . If it is null, nothing will happen. More...
 
static void Free< T > (ref T **ptr)
 Frees ptr . If it is null, nothing will happen. More...
 
static void Free< T > (ref T *ptr)
 Frees ptr . If it is null, nothing will happen. More...
 
static int GetFieldOffset ([NotNull] System.Reflection.FieldInfo field)
 Gets the offset of the specified field. More...
 
static QuantumUnsafeAllocResult GetMemoryTrackingResult ()
 Get the memory tracking result. More...
 
static int GetWordCount (int stride, int wordSize)
 Returns the word count for stride and a given word size. More...
 
static bool IsAligned (nint value, int align=DefaultAlignment)
 Returns true if value is aligned More...
 
static bool IsAligned (void *value, int align=DefaultAlignment)
 Returns true if value is aligned More...
 
static int MakeAligned (int value)
 Returns value aligned according to More...
 
static int MakeAligned (int value, int align)
 Returns value aligned according to align More...
 
static nint MakeAligned (nint value, int align)
 Returns value aligned according to align More...
 
static void Move ([NotNull] void *destination, [NotNull] void *source, int size)
 Moves a block of memory from the source to the destination. More...
 
static void Move (nint destination, nint source, nuint size)
 Moves a block of memory from the source to the destination. More...
 
static T Replace< T > (ref T a, T value)
 Replaces the value at x with value and returns the replaced value. More...
 
static T Replace< T > (T *a, T value)
 Replaces the value at x with value and returns the replaced value. More...
 
static void Set ([NotNull] void *ptr, byte value, int size)
 Initializes a block of memory with given value. More...
 
static void Set (nint ptr, byte value, nuint count)
 Initializes a block of memory with given value. More...
 
static void SetMemoryTrackingMode (QuantumUnsafeTrackingMode mode)
 
static void * Shrink (void *buffer, int currentSize, int newSize, [CallerFilePath] string callerFilePath=null, [CallerLineNumber] int callerLineNumber=0)
 Shrinks the allocated memory of the array of the type to a new size by copying the old contents and freeing the old memory. More...
 
static T * ShrinkArray< T > (T *buffer, int currentSize, int newSize, [CallerFilePath] string callerFilePath=null, [CallerLineNumber] int callerLineNumber=0)
 Shrinks the allocated memory of the array of the type to a new size by copying the old contents and freeing the old memory. More...
 
static T ** ShrinkPtrArray< T > (T **buffer, int currentSize, int newSize, [CallerFilePath] string callerFilePath=null, [CallerLineNumber] int callerLineNumber=0)
 Shrinks the allocated memory of the array of the type to a new size by copying the old contents and freeing the old memory. More...
 
static int SizeOf ([NotNull] Type type)
 Gets the size of the specified type. More...
 
static void Swap (void *a, void *b, int count)
 Swaps values between two locations in memory. More...
 
static void Swap< T > (ref T a, ref T b)
 Swaps values between two locations in memory. More...
 
static void Swap< T > (T *a, T *b)
 Swaps values between two locations in memory. More...
 
static bool TryFree (void *ptr)
 Attempts to free ptr . If null, will return false. If alloc tracking is enabled, will also return false for a pointer that has not been allocated by this class. More...
 
static bool TryFree (void *ptr, out QuantumUnsafeAllocInfo allocInfo)
 Attempts to free ptr . If null, will return false. If alloc tracking is enabled, will also return false for a pointer that has not been allocated by this class. More...
 

Static Public Attributes

const int DefaultAlignment = 8
 The default alignment of allocated blocks. More...
 

Detailed Description

Utility methods for memory operations.

Member Function Documentation

◆ AllocAndClearBlock() [1/11]

static int Quantum.QuantumUnsafe.AllocAndClearBlock ( int  size0,
int  size1,
out void *  ptr0,
out void *  ptr1,
int  align = DefaultAlignment 
)
inlinestatic

Allocates a block of memory and clears it.

◆ AllocAndClearBlock() [2/11]

static int Quantum.QuantumUnsafe.AllocAndClearBlock ( int  size0,
int  size1,
int  size2,
out void *  ptr0,
out void *  ptr1,
out void *  ptr2,
int  align = DefaultAlignment 
)
inlinestatic

Allocates a block of memory and clears it.

◆ AllocAndClearBlock() [3/11]

static int Quantum.QuantumUnsafe.AllocAndClearBlock ( int  size0,
int  size1,
int  size2,
int  size3,
out void *  ptr0,
out void *  ptr1,
out void *  ptr2,
out void *  ptr3,
int  align = DefaultAlignment 
)
inlinestatic

Allocates a block of memory and clears it.

◆ AllocAndClearBlock() [4/11]

static int Quantum.QuantumUnsafe.AllocAndClearBlock ( 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  align = DefaultAlignment 
)
inlinestatic

Allocates a block of memory and clears it.

◆ AllocAndClearBlock() [5/11]

static int Quantum.QuantumUnsafe.AllocAndClearBlock ( 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  align = DefaultAlignment 
)
inlinestatic

Allocates a block of memory and clears it.

◆ AllocAndClearBlock() [6/11]

static int Quantum.QuantumUnsafe.AllocAndClearBlock ( 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  align = DefaultAlignment 
)
inlinestatic

Allocates a block of memory and clears it.

◆ AllocAndClearBlock() [7/11]

static int Quantum.QuantumUnsafe.AllocAndClearBlock ( 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  align = DefaultAlignment 
)
inlinestatic

Allocates a block of memory and clears it.

◆ AllocAndClearBlock() [8/11]

static int Quantum.QuantumUnsafe.AllocAndClearBlock ( 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  align = DefaultAlignment 
)
inlinestatic

Allocates a block of memory and clears it.

◆ AllocAndClearBlock() [9/11]

static int Quantum.QuantumUnsafe.AllocAndClearBlock ( 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  align = DefaultAlignment 
)
inlinestatic

Allocates a block of memory and clears it.

◆ AllocAndClearBlock() [10/11]

static int Quantum.QuantumUnsafe.AllocAndClearBlock ( 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  align = DefaultAlignment 
)
inlinestatic

Allocates a block of memory and clears it.

◆ AllocAndClearBlock() [11/11]

static int Quantum.QuantumUnsafe.AllocAndClearBlock ( 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  align = DefaultAlignment 
)
inlinestatic

Allocates a block of memory and clears it.

◆ SetMemoryTrackingMode()

static void Quantum.QuantumUnsafe.SetMemoryTrackingMode ( QuantumUnsafeTrackingMode  mode)
inlinestatic

Parameters
mode

◆ GetMemoryTrackingResult()

static QuantumUnsafeAllocResult Quantum.QuantumUnsafe.GetMemoryTrackingResult ( )
static

Get the memory tracking result.

◆ Set() [1/2]

static void Quantum.QuantumUnsafe.Set ( nint  ptr,
byte  value,
nuint  count 
)
static

Initializes a block of memory with given value.

◆ Copy() [1/2]

static void Quantum.QuantumUnsafe.Copy ( nint  destination,
nint  source,
nuint  size 
)
static

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

◆ Move() [1/2]

static void Quantum.QuantumUnsafe.Move ( nint  destination,
nint  source,
nuint  size 
)
static

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

◆ Compare() [1/2]

static int Quantum.QuantumUnsafe.Compare ( nint  ptr1,
nint  ptr2,
nuint  size 
)
static

Compares two blocks of memory.

◆ Swap()

static void Quantum.QuantumUnsafe.Swap ( void *  a,
void *  b,
int  count 
)
inlinestatic

Swaps values between two locations in memory.

◆ Swap< T >() [1/2]

static void Quantum.QuantumUnsafe.Swap< T > ( T *  a,
T *  b 
)
inlinestatic

Swaps values between two locations in memory.

Type Constraints
T :unmanaged 

◆ Swap< T >() [2/2]

static void Quantum.QuantumUnsafe.Swap< T > ( ref T  a,
ref T  b 
)
inlinestatic

Swaps values between two locations in memory.

Type Constraints
T :unmanaged 

◆ Replace< T >() [1/2]

static T Quantum.QuantumUnsafe.Replace< T > ( T *  a,
T  value 
)
inlinestatic

Replaces the value at x with value and returns the replaced value.

Type Constraints
T :unmanaged 

◆ Replace< T >() [2/2]

static T Quantum.QuantumUnsafe.Replace< T > ( ref T  a,
T  value 
)
inlinestatic

Replaces the value at x with value and returns the replaced value.

Type Constraints
T :unmanaged 

◆ Alloc()

static void* Quantum.QuantumUnsafe.Alloc ( int  size,
int  align = DefaultAlignment,
[CallerFilePath] string  callerFilePath = null,
[CallerLineNumber] int  callerLineNumber = 0 
)
inlinestatic

Allocates a block of memory. The return address is 8-aligned.

◆ Alloc< T >()

static T* Quantum.QuantumUnsafe.Alloc< T > ( int  align = DefaultAlignment,
[CallerFilePath] string  callerFilePath = null,
[CallerLineNumber] int  callerLineNumber = 0 
)
inlinestatic

Allocates a block of memory. The return address is 8-aligned.

Type Constraints
T :unmanaged 

◆ AllocAndClear()

static void* Quantum.QuantumUnsafe.AllocAndClear ( int  size,
int  align = DefaultAlignment,
[CallerFilePath] string  callerFilePath = null,
[CallerLineNumber] int  callerLineNumber = 0 
)
inlinestatic

Allocates a block of memory. The memory is 0-initialized. The return address is 8-aligned.

◆ AllocAndClear< T >()

static T* Quantum.QuantumUnsafe.AllocAndClear< T > ( int  align = DefaultAlignment,
[CallerFilePath] string  callerFilePath = null,
[CallerLineNumber] int  callerLineNumber = 0 
)
inlinestatic

Allocates a block of memory. The memory is 0-initialized. The return address is 8-aligned.

Type Constraints
T :unmanaged 

◆ AllocAndClearArray< T >()

static T* Quantum.QuantumUnsafe.AllocAndClearArray< T > ( int  count,
int  align = DefaultAlignment,
[CallerFilePath] string  callerFilePath = null,
[CallerLineNumber] int  callerLineNumber = 0 
)
inlinestatic

Allocates a block of memory. The memory is 0-initialized. The return address is 8-aligned.

Type Constraints
T :unmanaged 

◆ AllocAndClearArray()

static void* Quantum.QuantumUnsafe.AllocAndClearArray ( int  count,
int  elementSize,
int  align = DefaultAlignment,
[CallerFilePath] string  callerFilePath = null,
[CallerLineNumber] int  callerLineNumber = 0 
)
inlinestatic

Allocates a block of memory. The memory is 0-initialized. The return address is 8-aligned.

◆ AllocAndClearPtrArray< T >()

static T** Quantum.QuantumUnsafe.AllocAndClearPtrArray< T > ( int  capacity,
int  align = DefaultAlignment,
[CallerFilePath] string  callerFilePath = null,
[CallerLineNumber] int  callerLineNumber = 0 
)
inlinestatic

Allocates a block of memory. The memory is 0-initialized. The return address is 8-aligned.

Type Constraints
T :unmanaged 

◆ Copy< T >() [1/3]

static void Quantum.QuantumUnsafe.Copy< T > ( T *  destination,
ReadOnlySpan< T >  source 
)
static

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

Type Constraints
T :unmanaged 
T :Copy 
T :new 
T :Span<T> 
T :destination 
T :source.Length 
T :source 

◆ Copy< T >() [2/3]

static void Quantum.QuantumUnsafe.Copy< T > ( Span< T >  destination,
T *  source 
)
static

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

Type Constraints
T :unmanaged 
T :Copy 
T :destination 
T :new 
T :Span<T> 
T :source 
T :destination.Length 

◆ Free() [1/2]

static void Quantum.QuantumUnsafe.Free ( void *  ptr)
inlinestatic

Frees ptr . If it is null, nothing will happen.

◆ Free() [2/2]

static void Quantum.QuantumUnsafe.Free ( ref void *  ptr)
inlinestatic

Frees ptr . If it is null, nothing will happen.

◆ Free< T >() [1/2]

static void Quantum.QuantumUnsafe.Free< T > ( ref T *  ptr)
inlinestatic

Frees ptr . If it is null, nothing will happen.

Type Constraints
T :unmanaged 

◆ Free< T >() [2/2]

static void Quantum.QuantumUnsafe.Free< T > ( ref T **  ptr)
inlinestatic

Frees ptr . If it is null, nothing will happen.

Type Constraints
T :unmanaged 

◆ ExpandArray< T >()

static T* Quantum.QuantumUnsafe.ExpandArray< T > ( T *  buffer,
int  currentSize,
int  newSize,
[CallerFilePath] string  callerFilePath = null,
[CallerLineNumber] int  callerLineNumber = 0 
)
inlinestatic

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

Type Constraints
T :unmanaged 

◆ ExpandPtrArray< T >()

static T** Quantum.QuantumUnsafe.ExpandPtrArray< T > ( T **  buffer,
int  currentSize,
int  newSize,
[CallerFilePath] string  callerFilePath = null,
[CallerLineNumber] int  callerLineNumber = 0 
)
inlinestatic

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

Type Constraints
T :unmanaged 

◆ Expand()

static void* Quantum.QuantumUnsafe.Expand ( void *  buffer,
int  currentSize,
int  newSize,
[CallerFilePath] string  callerFilePath = null,
[CallerLineNumber] int  callerLineNumber = 0 
)
inlinestatic

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

◆ MakeAligned() [1/3]

static nint Quantum.QuantumUnsafe.MakeAligned ( nint  value,
int  align 
)
inlinestatic

Returns value aligned according to align

◆ MakeAligned() [2/3]

static int Quantum.QuantumUnsafe.MakeAligned ( int  value,
int  align 
)
inlinestatic

Returns value aligned according to align

◆ MakeAligned() [3/3]

static int Quantum.QuantumUnsafe.MakeAligned ( int  value)
inlinestatic

Returns value aligned according to

◆ IsAligned() [1/2]

static bool Quantum.QuantumUnsafe.IsAligned ( nint  value,
int  align = DefaultAlignment 
)
inlinestatic

Returns true if value is aligned

◆ IsAligned() [2/2]

static bool Quantum.QuantumUnsafe.IsAligned ( void *  value,
int  align = DefaultAlignment 
)
static

Returns true if value is aligned

◆ GetWordCount()

static int Quantum.QuantumUnsafe.GetWordCount ( int  stride,
int  wordSize 
)
inlinestatic

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

◆ TryFree() [1/2]

static bool Quantum.QuantumUnsafe.TryFree ( void *  ptr)
inlinestatic

Attempts to free ptr . If null, will return false. If alloc tracking is enabled, will also return false for a pointer that has not been allocated by this class.

◆ TryFree() [2/2]

static bool Quantum.QuantumUnsafe.TryFree ( void *  ptr,
out QuantumUnsafeAllocInfo  allocInfo 
)
inlinestatic

Attempts to free ptr . If null, will return false. If alloc tracking is enabled, will also return false for a pointer that has not been allocated by this class.

◆ Move() [2/2]

static void Quantum.QuantumUnsafe.Move ( [NotNull] void *  destination,
[NotNull] void *  source,
int  size 
)
inlinestatic

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

◆ Copy() [2/2]

static void Quantum.QuantumUnsafe.Copy ( [NotNull] void *  destination,
[NotNull] void *  source,
int  size 
)
inlinestatic

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

◆ Clear()

static void Quantum.QuantumUnsafe.Clear ( [NotNull] void *  ptr,
int  size 
)
inlinestatic

Clears a block of memory by setting it to zero.

◆ Set() [2/2]

static void Quantum.QuantumUnsafe.Set ( [NotNull] void *  ptr,
byte  value,
int  size 
)
inlinestatic

Initializes a block of memory with given value.

◆ Compare() [2/2]

static int Quantum.QuantumUnsafe.Compare ( [NotNull] void *  ptr1,
[NotNull] void *  ptr2,
int  size 
)
inlinestatic

Compares two blocks of memory.

◆ Copy< T >() [3/3]

static void Quantum.QuantumUnsafe.Copy< T > ( Span< T >  destination,
ReadOnlySpan< T >  source 
)
inlinestatic

Copy from source to destination, with CopyTo semantics: destination must be the same size or bigger than source. If source is smaller than destination the excess part of destination is not written to.

Type Constraints
T :unmanaged 

◆ CopyToExact< T >()

static void Quantum.QuantumUnsafe.CopyToExact< T > ( Span< T >  destination,
ReadOnlySpan< T >  source 
)
inlinestatic

Copy from source to destination, like CopyTo but source and destination must be the same size.

Type Constraints
T :unmanaged 

◆ Clear< T >()

static void Quantum.QuantumUnsafe.Clear< T > ( Span< T >  span)
inlinestatic

Clears a block of memory by setting it to zero.

Type Constraints
T :unmanaged 

◆ SizeOf()

static int Quantum.QuantumUnsafe.SizeOf ( [NotNull] Type  type)
inlinestatic

Gets the size of the specified type.

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

◆ GetFieldOffset()

static int Quantum.QuantumUnsafe.GetFieldOffset ( [NotNull] System.Reflection.FieldInfo  field)
inlinestatic

Gets the offset of the specified field.

◆ AllocInternal()

static void* Quantum.QuantumUnsafe.AllocInternal ( int  size,
int  align = DefaultAlignment 
)
inlinestatic

Allocates a block of memory.

◆ ShrinkArray< T >()

static T* Quantum.QuantumUnsafe.ShrinkArray< T > ( T *  buffer,
int  currentSize,
int  newSize,
[CallerFilePath] string  callerFilePath = null,
[CallerLineNumber] int  callerLineNumber = 0 
)
inlinestatic

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

Type Constraints
T :unmanaged 

◆ ShrinkPtrArray< T >()

static T** Quantum.QuantumUnsafe.ShrinkPtrArray< T > ( T **  buffer,
int  currentSize,
int  newSize,
[CallerFilePath] string  callerFilePath = null,
[CallerLineNumber] int  callerLineNumber = 0 
)
inlinestatic

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

Type Constraints
T :unmanaged 

◆ Shrink()

static void* Quantum.QuantumUnsafe.Shrink ( void *  buffer,
int  currentSize,
int  newSize,
[CallerFilePath] string  callerFilePath = null,
[CallerLineNumber] int  callerLineNumber = 0 
)
inlinestatic

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

Member Data Documentation

◆ DefaultAlignment

const int Quantum.QuantumUnsafe.DefaultAlignment = 8
static

The default alignment of allocated blocks.