Click or drag to resize

MemoryHelper Methods

The MemoryHelper type exposes the following members.

Methods
 NameDescription
Public methodStatic memberAllocateMemory Allocates unmanaged memory. This memory should only be freed by this helper.
Public methodStatic memberClearMemory Clears the memory to zero.
Public methodStatic memberCopyMemory Performs a memcopy that copies data from the memory pointed to by the source pointer to the memory pointer by the destination pointer.
Public methodStatic memberFreeMemory Frees unmanaged memory that was allocated by this helper.
Public methodStatic memberFreeNativeArrayT Frees an unmanaged array and performs cleanup for each value. Optionally can free an array of pointers. This can be used on any type that can be marshaled into unmanaged memory.
Public methodStatic memberFromNativeArrayT(IntPtr, Int32) Marshals an array of blittable structs from a c-style unmanaged array (void*). This should not be used on non-blittable types that require marshaling by the runtime (e.g. has MarshalAs attributes).
Public methodStatic memberFromNativeArrayManaged, Native(IntPtr, Int32, Boolean) Marshals an array of managed values from a c-style unmanaged array (void*). This also can optionally marshal from an unmanaged array of pointers (void**).
Public methodStatic memberFromNativePointerManaged, Native Marshals a managed value from unmanaged memory.
Public methodStatic memberMarshalPointerT Convienence method for marshaling a structure to a pointer. Only use if the type is not blittable, otherwise use the write methods for blittable types.
Public methodStatic memberMarshalSizeOfT Computes the size of the struct type using Marshal SizeOf. Only use if the type is not blittable, thus requiring marshaling by the runtime, (e.g. has MarshalAs attributes), otherwise use the SizeOf methods for blittable types.
Public methodStatic memberMarshalStructureT(IntPtr) Convienence method for marshaling a pointer to a structure. Only use if the type is not blittable, otherwise use the read methods for blittable types.
Public methodStatic memberMarshalStructureT(IntPtr, T) Convienence method for marshaling a pointer to a structure. Only use if the type is not blittable, otherwise use the read methods for blittable types.
Public methodStatic memberReadT(IntPtr) Reads a single element from the memory location.
Public methodStatic memberReadT(IntPtr, T) Reads a single element from the memory location.
Public methodStatic memberReadT(IntPtr, T, Int32, Int32) Reads data from the memory location into the array.
Public methodStatic memberReadStreamFully Reads a stream until the end is reached into a byte array. Based on Jon Skeet's implementation. It is up to the caller to dispose of the stream.
Public methodStatic memberSizeOfT Computes the size of the struct type.
Public methodStatic memberSizeOfT(T) Computes the size of the struct array.
Public methodStatic memberToNativeArrayT(ListT) Marshals a list of blittable structs to a c-style unmanaged array (void*). This should not be used on non-blittable types that require marshaling by the runtime (e.g. has MarshalAs attributes).
Public methodStatic memberToNativeArrayT(T) Marshals an array of blittable structs to a c-style unmanaged array (void*). This should not be used on non-blittable types that require marshaling by the runtime (e.g. has MarshalAs attributes).
Public methodStatic memberToNativeArrayManaged, Native(IReadOnlyCollectionManaged, Boolean) Marshals an array of managed values to a c-style unmanaged array (void*). This also can optionally marshal to an unmanaged array of pointers (void**).
Public methodStatic memberToNativePointerManaged, Native Marshals a managed value to unmanaged memory.
Public methodStatic memberWriteT(IntPtr, T) Writes a single element to the memory location.
Public methodStatic memberWriteT(IntPtr, T, Int32, Int32) Writes data from the array to the memory location.
Public methodStatic memberWriteT(IntPtr, ListT, Int32, Int32) Writes data from the list to the memory location.
Top
See Also