Class UnmanagedMemory
Represents unstructured unmanaged memory.
Inherited Members
Namespace: DotNext.Runtime.InteropServices
Assembly: DotNext.Unsafe.dll
Syntax
public sealed class UnmanagedMemory : UnmanagedMemoryHandle, ICloneable, IEquatable<UnmanagedMemoryHandle>, IUnmanagedMemory, IDisposable
Constructors
| Improve this Doc View SourceUnmanagedMemory(Int64, Boolean)
Allocates the block of unmanaged memory.
Declaration
public UnmanagedMemory(long size, bool zeroMem = true)
Parameters
Type | Name | Description |
---|---|---|
Int64 | size | The size of unmanaged memory to be allocated, in bytes. |
Boolean | zeroMem | Sets all bytes of allocated memory to zero. |
Properties
| Improve this Doc View SourceSize
Gets size of allocated unmanaged memory, in bytes.
Declaration
public override long Size { get; }
Property Value
Type | Description |
---|---|
Int64 |
Overrides
Methods
| Improve this Doc View SourceCopy()
Creates bitwise copy of the unmanaged memory.
Declaration
public UnmanagedMemory Copy()
Returns
Type | Description |
---|---|
UnmanagedMemory | The independent copy of unmanaged memory. |
ReadFrom(Byte[])
Copies bytes from the memory location to the managed array.
Declaration
public long ReadFrom(byte[] source)
Parameters
Type | Name | Description |
---|---|---|
Byte[] | source | The source array. |
Returns
Type | Description |
---|---|
Int64 | The actual number of copied bytes. |
ReadFrom(Byte[], Int64, Int64)
Copies bytes from the specified array into the memory block identified by this object.
Declaration
public long ReadFrom(byte[] source, long offset, long count)
Parameters
Type | Name | Description |
---|---|---|
Byte[] | source | The source array. |
Int64 | offset | The position in the source array from which copying begins. |
Int64 | count | The number of bytes to be copied. |
Returns
Type | Description |
---|---|
Int64 | Actual number of copied bytes. |
Reallocate(Int64)
Resizes a block of memory represented by this instance.
Declaration
public void Reallocate(long size)
Parameters
Type | Name | Description |
---|---|---|
Int64 | size | The new number of bytes in the unmanaged array. |
WriteTo(Byte[])
Copies bytes from the memory location to the managed array.
Declaration
public long WriteTo(byte[] destination)
Parameters
Type | Name | Description |
---|---|---|
Byte[] | destination | The destination array. |
Returns
Type | Description |
---|---|
Int64 | The actual number of copied bytes. |
WriteTo(Byte[], Int64, Int64)
Copies bytes from the memory location to the managed array.
Declaration
public long WriteTo(byte[] destination, long offset, long count)
Parameters
Type | Name | Description |
---|---|---|
Byte[] | destination | The destination array. |
Int64 | offset | The position in the destination array from which copying begins. |
Int64 | count | The number of bytes to be copied. |
Returns
Type | Description |
---|---|
Int64 | The actual number of copied bytes. |
Operators
| Improve this Doc View SourceImplicit(UnmanagedMemory to Pointer<Byte>)
Gets a pointer to the allocated unmanaged memory.
Declaration
public static implicit operator Pointer<byte>(UnmanagedMemory owner)
Parameters
Type | Name | Description |
---|---|---|
UnmanagedMemory | owner | The owner of allocated unmanaged memory. |
Returns
Type | Description |
---|---|
Pointer<Byte> |
Implicit(UnmanagedMemory to Span<Byte>)
Gets a span from the specified instance.
Declaration
public static implicit operator Span<byte>(UnmanagedMemory owner)
Parameters
Type | Name | Description |
---|---|---|
UnmanagedMemory | owner | The owner of allocated unmanaged memory. |
Returns
Type | Description |
---|---|
Span<Byte> |