mirror of
https://github.com/Ryujinx/SDL2-CS.git
synced 2025-01-22 09:01:00 +00:00
stackalloc for UTF8_ToManaged
This commit is contained in:
parent
a16e9951f7
commit
f26b55e8be
|
@ -89,9 +89,10 @@ namespace SDL2
|
|||
);
|
||||
#else
|
||||
/* Old C# requires an extra memcpy, bleh! */
|
||||
byte[] bytes = new byte[ptr - (byte*) s];
|
||||
Marshal.Copy(s, bytes, 0, bytes.Length);
|
||||
string result = System.Text.Encoding.UTF8.GetString(bytes);
|
||||
int len = (int) (ptr - (byte*) s);
|
||||
char* chars = stackalloc char[len];
|
||||
System.Text.Encoding.UTF8.GetChars((byte*) s, len, chars, len);
|
||||
string result = new string(chars);
|
||||
#endif
|
||||
|
||||
/* Some SDL functions will malloc, we have to free! */
|
||||
|
|
Loading…
Reference in a new issue