Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
FixedWSTRMarshaler.cs
Go to the documentation of this file.
1namespace System.StubHelpers;
2
3internal static class FixedWSTRMarshaler
4{
5 internal unsafe static void ConvertToNative(string strManaged, IntPtr nativeHome, int length)
6 {
7 ReadOnlySpan<char> readOnlySpan = strManaged;
8 Span<char> destination = new Span<char>((void*)nativeHome, length);
9 int num = Math.Min(readOnlySpan.Length, length - 1);
10 readOnlySpan.Slice(0, num).CopyTo(destination);
11 destination[num] = '\0';
12 }
13
14 internal unsafe static string ConvertToManaged(IntPtr nativeHome, int length)
15 {
16 int num = SpanHelpers.IndexOf(ref *(char*)(void*)nativeHome, '\0', length);
17 if (num != -1)
18 {
19 length = num;
20 }
21 return new string((char*)(void*)nativeHome, 0, length);
22 }
23}
static byte Min(byte val1, byte val2)
Definition Math.cs:912
static int IndexOf(ref byte searchSpace, int searchSpaceLength, ref byte value, int valueLength)
static unsafe void ConvertToNative(string strManaged, IntPtr nativeHome, int length)
static unsafe string ConvertToManaged(IntPtr nativeHome, int length)
ReadOnlySpan< T > Slice(int start)