Show / Hide Table of Contents

Class MarshalTk

Contains extra marshalling utilities that aren't available in the normal Marshal class.

Inheritance
object
MarshalTk
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: OpenTK.Core.Native
Assembly: OpenTK.Core.dll
Syntax
public static class MarshalTk

Methods

FreeAnsiStringArrayPtr(byte**, uint)

Frees unmanaged ansi string arrays allocated by MarshalStringArrayToAnsiStringArrayPtr(ReadOnlySpan<string>, out uint).

Declaration
public static void FreeAnsiStringArrayPtr(byte** strArrayPtr, uint count)
Parameters
Type Name Description
byte** strArrayPtr

The unmanaged ansi string array.

uint count

The number of strings in the array.

FreeStringArrayPtr(nint, int)

Frees a marshaled string that allocated by MarshalStringArrayToPtr.

Declaration
public static void FreeStringArrayPtr(nint ptr, int length)
Parameters
Type Name Description
nint ptr

An unmanaged pointer allocated with MarshalStringArrayToPtr.

int length

The length of the string array.

FreeStringPtr(nint)

Frees a marshaled string that allocated by MarshalStringToPtr.

Declaration
public static void FreeStringPtr(nint ptr)
Parameters
Type Name Description
nint ptr

An unmanaged pointer allocated with MarshalStringToPtr.

MarshalAnsiStringArrayPtrToStringArray(byte**, uint)

Marshals a byte** ansi string array into a string[].

Declaration
public static string[] MarshalAnsiStringArrayPtrToStringArray(byte** strArrayPtr, uint length)
Parameters
Type Name Description
byte** strArrayPtr

The ansi string array pointer.

uint length

The number of strings in the array.

Returns
Type Description
string[]

The managed string array.

MarshalPtrToString(nint)

Marshals a pointer to a null-terminated byte array to a new System.String. This method supports OpenTK and is not intended to be called by user code.

Declaration
public static string MarshalPtrToString(nint ptr)
Parameters
Type Name Description
nint ptr

A pointer to a null-terminated byte array.

Returns
Type Description
string

A System.String with the data from ptr.

MarshalStringArrayToAnsiStringArrayPtr(ReadOnlySpan<string>, out uint)

Converts a span of strings into an unmanged ansi string array. Use FreeAnsiStringArrayPtr(byte**, uint) to free the array.

Declaration
public static byte** MarshalStringArrayToAnsiStringArrayPtr(ReadOnlySpan<string> stringArray, out uint count)
Parameters
Type Name Description
ReadOnlySpan<string> stringArray

The span of strings to marshal.

uint count

The number of strings in the unmanged array. The same as the length of the array.

Returns
Type Description
byte**

The unmanaged ansi string array.

MarshalStringArrayToPtr(string[])

Marshals a System.String array to unmanaged memory by calling Marshal.AllocHGlobal for each element.

Declaration
public static nint MarshalStringArrayToPtr(string[] strArray)
Parameters
Type Name Description
string[] strArray

The string array to marshal.

Returns
Type Description
nint

An unmanaged pointer to an array of null-terminated strings.

MarshalStringToPtr(string)

Marshal a System.String to unmanaged memory. The resulting string is encoded in UTF8 and must be freed with FreeStringPtr.

Declaration
public static nint MarshalStringToPtr(string str)
Parameters
Type Name Description
string str

The System.String to marshal.

Returns
Type Description
nint

An unmanaged pointer containing the marshaled string. This pointer must be freed with FreeStringPtr.

In this article
  • Methods
    • FreeAnsiStringArrayPtr(byte**, uint)
    • FreeStringArrayPtr(nint, int)
    • FreeStringPtr(nint)
    • MarshalAnsiStringArrayPtrToStringArray(byte**, uint)
    • MarshalPtrToString(nint)
    • MarshalStringArrayToAnsiStringArrayPtr(ReadOnlySpan<string>, out uint)
    • MarshalStringArrayToPtr(string[])
    • MarshalStringToPtr(string)
Back to top Generated by DocFX