Mono Class Library: Mono.Unix.UnixMarshal Overview | Members

Mono.Unix.UnixMarshal.StringToHeap Method

Allocates a copy of s on the system heap in the encoding encoding.

public static IntPtr StringToHeap (string s, System.Text.Encoding encoding)

See Also

UnixMarshal.FreeHeap

Parameters

s
A string to copy into the system heap.
encoding
A System.Text.Encoding specifying which encoding to marshal the string into.

Returns

A IntPtr containing a pointer on the system heap containing the marshaled string. If s is null, then IntPtr.Zero is returned.

Exceptions

TypeReason
ArgumentNullExceptionencoding is null.
NotSupportedException There was an error marshaling s into the specified encoding encoding.
Mono.Unix.UnixIOException Unable to allocate enough memory for the marshaled string. [Mono.Unix.Native.Errno.ENOMEM]

Remarks

The pointer returned should be freed with UnixMarshal.FreeHeap to avoid a memory leak.

This is identical to UnixMarshal.StringToHeap(s, 0, s.Length, UnixMarshal.Instance).

Requirements

Namespace: Mono.Unix
Assembly: Mono.Posix (in Mono.Posix.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0