You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the current API, strings that need to be passed over to the native side are always allocated on the heap with Marshal.StringToHGlobalAnsi using the NativeString helper struct.
Example:
{stringmanagedString="Hello World";usingNativeStringnativeString=(NativeString)managedString;// Heap allocation
random_function(nativeString);// NativeStrings are implicitly casted to byte*/sbyte*// String is freed at the end of the scope}
Heap allocations are unnecessary in places where strings are freed immediately after use and should be rewritten to use stack allocated memory instead.
In the current API, strings that need to be passed over to the native side are always allocated on the heap with
Marshal.StringToHGlobalAnsi
using theNativeString
helper struct.Example:
Heap allocations are unnecessary in places where strings are freed immediately after use and should be rewritten to use stack allocated memory instead.
Example:
The text was updated successfully, but these errors were encountered: