mirror of
https://github.com/glfw/glfw.git
synced 2025-06-14 19:52:14 +00:00
Fixed memory leak in cocoa _glfwPlatformGetKeyName
This commit is contained in:
parent
9c68e11f2f
commit
363ec64321
@ -108,6 +108,7 @@ typedef struct _GLFWlibraryNS
|
||||
GLboolean cursorHidden;
|
||||
|
||||
char* clipboardString;
|
||||
char* keyName;
|
||||
|
||||
_GLFWjoy joysticks[GLFW_JOYSTICK_LAST + 1];
|
||||
} _GLFWlibraryNS;
|
||||
|
@ -1098,7 +1098,11 @@ void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode)
|
||||
|
||||
const char* _glfwPlatformGetKeyName(int key)
|
||||
{
|
||||
// First try to translate virtual key mac os x style
|
||||
// free temp keyname
|
||||
free(_glfw.ns.keyName);
|
||||
_glfw.ns.keyName = 0;
|
||||
|
||||
// Try to translate virtual key mac os x style
|
||||
UInt16 vKey = 0;
|
||||
switch(key)
|
||||
{
|
||||
@ -1189,8 +1193,8 @@ const char* _glfwPlatformGetKeyName(int key)
|
||||
if (actualStringLength > 0 && status == noErr)
|
||||
{
|
||||
NSString* tempNS = [[NSString stringWithCharacters:unicodeString length:(NSUInteger)actualStringLength] uppercaseString];
|
||||
char* pTodoFree = strdup([tempNS UTF8String]);
|
||||
return pTodoFree;
|
||||
_glfw.ns.keyName = strdup([tempNS UTF8String]);
|
||||
return _glfw.ns.keyName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user