Fixed memory corruption on string return type marshaling

This commit is contained in:
Stefanos A 2013-12-15 20:57:25 +01:00
parent 4b3aac38b6
commit e9f54dc61e

View file

@ -206,7 +206,14 @@ namespace OpenTK.Platform.SDL2
[SuppressUnmanagedCodeSecurity]
[DllImport(lib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_JoystickName", ExactSpelling = true)]
public static extern string JoystickName(IntPtr joystick);
static extern IntPtr JoystickNameInternal(IntPtr joystick);
public static string JoystickName(IntPtr joystick)
{
unsafe
{
return new string((sbyte*)JoystickNameInternal(joystick));
}
}
[SuppressUnmanagedCodeSecurity]
[DllImport(lib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_JoystickNumAxes", ExactSpelling = true)]