mirror of
https://github.com/gwm17/glfw.git
synced 2025-02-07 06:38:50 -05:00
Fixed Win32 joystick name memory leak.
This commit is contained in:
parent
b72a97d531
commit
d1132cb3d1
|
@ -192,6 +192,8 @@ int _glfwPlatformInit(void)
|
||||||
|
|
||||||
_glfwInitTimer();
|
_glfwInitTimer();
|
||||||
|
|
||||||
|
_glfwInitJoysticks();
|
||||||
|
|
||||||
return GL_TRUE;
|
return GL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,7 +214,7 @@ void _glfwPlatformTerminate(void)
|
||||||
_glfw.win32.classAtom = 0;
|
_glfw.win32.classAtom = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Remove keyboard hook
|
_glfwTerminateJoysticks();
|
||||||
|
|
||||||
freeLibraries();
|
freeLibraries();
|
||||||
|
|
||||||
|
|
|
@ -71,6 +71,32 @@ static float calcJoystickPos(DWORD pos, DWORD min, DWORD max)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
////// GLFW internal API //////
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
//========================================================================
|
||||||
|
// Initialize joystick interface
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
|
void _glfwInitJoysticks(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//========================================================================
|
||||||
|
// Close all opened joystick handles
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
|
void _glfwTerminateJoysticks(void)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < GLFW_JOYSTICK_LAST; i++)
|
||||||
|
free(_glfw.win32.joystick[i].name);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
////// GLFW platform API //////
|
////// GLFW platform API //////
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -235,9 +261,9 @@ const char* _glfwPlatformGetJoystickName(int joy)
|
||||||
|
|
||||||
_glfw_joyGetDevCaps(i, &jc, sizeof(JOYCAPS));
|
_glfw_joyGetDevCaps(i, &jc, sizeof(JOYCAPS));
|
||||||
|
|
||||||
free(_glfw.win32.joyNames[i]);
|
free(_glfw.win32.joystick[i].name);
|
||||||
_glfw.win32.joyNames[i] = _glfwCreateUTF8FromWideString(jc.szPname);
|
_glfw.win32.joystick[i].name = _glfwCreateUTF8FromWideString(jc.szPname);
|
||||||
|
|
||||||
return _glfw.win32.joyNames[i];
|
return _glfw.win32.joystick[i].name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -189,7 +189,9 @@ typedef struct _GLFWlibraryWin32
|
||||||
} winmm;
|
} winmm;
|
||||||
#endif // _GLFW_NO_DLOAD_WINMM
|
#endif // _GLFW_NO_DLOAD_WINMM
|
||||||
|
|
||||||
char* joyNames[GLFW_JOYSTICK_LAST + 1];
|
struct {
|
||||||
|
char* name;
|
||||||
|
} joystick[GLFW_JOYSTICK_LAST + 1];
|
||||||
|
|
||||||
} _GLFWlibraryWin32;
|
} _GLFWlibraryWin32;
|
||||||
|
|
||||||
|
@ -215,6 +217,10 @@ char* _glfwCreateUTF8FromWideString(const WCHAR* source);
|
||||||
// Time
|
// Time
|
||||||
void _glfwInitTimer(void);
|
void _glfwInitTimer(void);
|
||||||
|
|
||||||
|
// Joystick input
|
||||||
|
void _glfwInitJoysticks(void);
|
||||||
|
void _glfwTerminateJoysticks(void);
|
||||||
|
|
||||||
// OpenGL support
|
// OpenGL support
|
||||||
int _glfwCreateContext(_GLFWwindow* window,
|
int _glfwCreateContext(_GLFWwindow* window,
|
||||||
const _GLFWwndconfig* wndconfig,
|
const _GLFWwndconfig* wndconfig,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user