Class UnmanagedMemory
Provides native memory allocation facilities.
Inherited Members
Namespace: DotNext.Buffers
Assembly: DotNext.Unsafe.dll
Syntax
public static class UnmanagedMemory
Methods
| Edit this page View SourceAllocateZeroed<T>(int)
Allocates and zeroes a block of unmanaged memory of the specified size, in elements.
Declaration
[CLSCompliant(false)]
public static IUnmanagedMemory<T> AllocateZeroed<T>(int length) where T : unmanaged
Parameters
Type | Name | Description |
---|---|---|
int | length | The number of elements to be allocated in unmanaged memory. |
Returns
Type | Description |
---|---|
IUnmanagedMemory<T> | The object representing allocated unmanaged memory. |
Type Parameters
Name | Description |
---|---|
T | The type of the elements in the unmanaged memory block. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException |
|
Allocate<T>(int)
Allocates a block of unmanaged memory of the specified size, in elements.
Declaration
[CLSCompliant(false)]
public static IUnmanagedMemory<T> Allocate<T>(int length) where T : unmanaged
Parameters
Type | Name | Description |
---|---|---|
int | length | The number of elements to be allocated in unmanaged memory. |
Returns
Type | Description |
---|---|
IUnmanagedMemory<T> | The object representing allocated unmanaged memory. |
Type Parameters
Name | Description |
---|---|
T | The type of the elements in the unmanaged memory block. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException |
|
AsMemory<T>(T*, int)
Wraps unmanaged pointer to Memory<T>.
Declaration
[CLSCompliant(false)]
public static Memory<T> AsMemory<T>(T* pointer, int length) where T : unmanaged
Parameters
Type | Name | Description |
---|---|---|
T* | pointer | The pointer to a sequence of elements. |
int | length | The number of elements. |
Returns
Type | Description |
---|---|
Memory<T> |
Type Parameters
Name | Description |
---|---|
T | The type of elements in the memory. |
GetAllocator<T>(bool)
Gets allocator of unmanaged memory.
Declaration
public static MemoryAllocator<T> GetAllocator<T>(bool zeroMem) where T : unmanaged
Parameters
Type | Name | Description |
---|---|---|
bool | zeroMem | true to set all bits in the memory to zero; otherwise, false. |
Returns
Type | Description |
---|---|
MemoryAllocator<T> | The unmanaged memory allocator. |
Type Parameters
Name | Description |
---|---|
T | The type of the elements in the memory block. |