mirror of
https://github.com/gwm17/glfw.git
synced 2024-11-23 10:48:51 -05:00
Fixing memory leak in cocoa_joystick
Making sure that propsRef and valueRef get released no matter when we break out of the loop. Resolves #231.
This commit is contained in:
parent
a70bcb97bb
commit
b4c03b992c
|
@ -343,6 +343,7 @@ void _glfwInitJoysticks(void)
|
||||||
{
|
{
|
||||||
// This device is not relevant to GLFW
|
// This device is not relevant to GLFW
|
||||||
CFRelease(valueRef);
|
CFRelease(valueRef);
|
||||||
|
CFRelease(propsRef);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -360,6 +361,7 @@ void _glfwInitJoysticks(void)
|
||||||
{
|
{
|
||||||
// This device is not relevant to GLFW
|
// This device is not relevant to GLFW
|
||||||
CFRelease(valueRef);
|
CFRelease(valueRef);
|
||||||
|
CFRelease(propsRef);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -376,7 +378,11 @@ void _glfwInitJoysticks(void)
|
||||||
&score);
|
&score);
|
||||||
|
|
||||||
if (kIOReturnSuccess != result)
|
if (kIOReturnSuccess != result)
|
||||||
|
{
|
||||||
|
CFRelease(valueRef);
|
||||||
|
CFRelease(propsRef);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
plugInResult = (*ppPlugInInterface)->QueryInterface(
|
plugInResult = (*ppPlugInInterface)->QueryInterface(
|
||||||
ppPlugInInterface,
|
ppPlugInInterface,
|
||||||
|
@ -384,7 +390,11 @@ void _glfwInitJoysticks(void)
|
||||||
(void *) &(joystick->interface));
|
(void *) &(joystick->interface));
|
||||||
|
|
||||||
if (plugInResult != S_OK)
|
if (plugInResult != S_OK)
|
||||||
|
{
|
||||||
|
CFRelease(valueRef);
|
||||||
|
CFRelease(propsRef);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
(*ppPlugInInterface)->Release(ppPlugInInterface);
|
(*ppPlugInInterface)->Release(ppPlugInInterface);
|
||||||
|
|
||||||
|
@ -419,6 +429,7 @@ void _glfwInitJoysticks(void)
|
||||||
(void*) joystick);
|
(void*) joystick);
|
||||||
CFRelease(valueRef);
|
CFRelease(valueRef);
|
||||||
}
|
}
|
||||||
|
CFRelease(propsRef);
|
||||||
|
|
||||||
joystick->axes = calloc(CFArrayGetCount(joystick->axisElements),
|
joystick->axes = calloc(CFArrayGetCount(joystick->axisElements),
|
||||||
sizeof(float));
|
sizeof(float));
|
||||||
|
|
Loading…
Reference in New Issue
Block a user