зеркало из https://github.com/stride3d/SDL2-CS.git
Fix Win32 UTF8 marshaling
This commit is contained in:
Родитель
f29dbb7e4d
Коммит
2e9752838d
|
@ -80,7 +80,7 @@ namespace SDL2
|
|||
throw new ArgumentException("ManagedObj must be a string.", "ManagedObj");
|
||||
}
|
||||
var bytes = Encoding.UTF8.GetBytes(str);
|
||||
var mem = Marshal.AllocHGlobal(bytes.Length + 1);
|
||||
var mem = SDL.SDL_malloc((IntPtr) bytes.Length + 1);
|
||||
Marshal.Copy(bytes, 0, mem, bytes.Length);
|
||||
((byte*)mem)[bytes.Length] = 0;
|
||||
return mem;
|
||||
|
@ -94,7 +94,7 @@ namespace SDL2
|
|||
{
|
||||
if (!_leaveAllocated)
|
||||
{
|
||||
Marshal.FreeHGlobal(pNativeData);
|
||||
SDL.SDL_free(pNativeData);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -60,6 +60,14 @@ namespace SDL2
|
|||
SDL_TRUE = 1
|
||||
}
|
||||
|
||||
/* malloc/free are used by the marshaler! -flibit */
|
||||
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern IntPtr SDL_malloc(IntPtr size);
|
||||
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern void SDL_free(IntPtr memblock);
|
||||
|
||||
#endregion
|
||||
|
||||
#region SDL_rwops.h
|
||||
|
|
Загрузка…
Ссылка в новой задаче