mirror of
https://github.com/glfw/glfw.git
synced 2024-11-26 14:24:35 +00:00
Assume malloc works.
This commit is contained in:
parent
51ee3a5c0a
commit
26e8fde8fb
@ -134,11 +134,6 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* count)
|
|||||||
size = 4;
|
size = 4;
|
||||||
|
|
||||||
monitors = (_GLFWmonitor**) realloc(monitors, sizeof(_GLFWmonitor*) * size);
|
monitors = (_GLFWmonitor**) realloc(monitors, sizeof(_GLFWmonitor*) * size);
|
||||||
if (!monitors)
|
|
||||||
{
|
|
||||||
// TODO: wat
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ZeroMemory(&display, sizeof(DISPLAY_DEVICE));
|
ZeroMemory(&display, sizeof(DISPLAY_DEVICE));
|
||||||
@ -250,23 +245,12 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found)
|
|||||||
|
|
||||||
if (*found == count)
|
if (*found == count)
|
||||||
{
|
{
|
||||||
void* larger;
|
|
||||||
|
|
||||||
if (count)
|
if (count)
|
||||||
count *= 2;
|
count *= 2;
|
||||||
else
|
else
|
||||||
count = 128;
|
count = 128;
|
||||||
|
|
||||||
larger = realloc(result, count * sizeof(GLFWvidmode));
|
result = (GLFWvidmode*) realloc(result, count * sizeof(GLFWvidmode));
|
||||||
if (!larger)
|
|
||||||
{
|
|
||||||
free(result);
|
|
||||||
|
|
||||||
_glfwInputError(GLFW_OUT_OF_MEMORY, NULL);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
result = (GLFWvidmode*) larger;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
result[*found] = mode;
|
result[*found] = mode;
|
||||||
|
@ -81,23 +81,7 @@ static int openJoystickDevice(int joy, const char* path)
|
|||||||
_glfw.x11.joystick[joy].numButtons = (int) numButtons;
|
_glfw.x11.joystick[joy].numButtons = (int) numButtons;
|
||||||
|
|
||||||
_glfw.x11.joystick[joy].axis = (float*) malloc(sizeof(float) * numAxes);
|
_glfw.x11.joystick[joy].axis = (float*) malloc(sizeof(float) * numAxes);
|
||||||
if (_glfw.x11.joystick[joy].axis == NULL)
|
|
||||||
{
|
|
||||||
close(fd);
|
|
||||||
|
|
||||||
_glfwInputError(GLFW_OUT_OF_MEMORY, NULL);
|
|
||||||
return GL_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
_glfw.x11.joystick[joy].button = (unsigned char*) malloc(numButtons);
|
_glfw.x11.joystick[joy].button = (unsigned char*) malloc(numButtons);
|
||||||
if (_glfw.x11.joystick[joy].button == NULL)
|
|
||||||
{
|
|
||||||
free(_glfw.x11.joystick[joy].axis);
|
|
||||||
close(fd);
|
|
||||||
|
|
||||||
_glfwInputError(GLFW_OUT_OF_MEMORY, NULL);
|
|
||||||
return GL_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
_glfw.x11.joystick[joy].present = GL_TRUE;
|
_glfw.x11.joystick[joy].present = GL_TRUE;
|
||||||
#endif // __linux__
|
#endif // __linux__
|
||||||
|
@ -286,11 +286,6 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found)
|
|||||||
oi = XRRGetOutputInfo(_glfw.x11.display, sr, monitor->x11.output);
|
oi = XRRGetOutputInfo(_glfw.x11.display, sr, monitor->x11.output);
|
||||||
|
|
||||||
result = (GLFWvidmode*) malloc(sizeof(GLFWvidmode) * oi->nmode);
|
result = (GLFWvidmode*) malloc(sizeof(GLFWvidmode) * oi->nmode);
|
||||||
if (!result)
|
|
||||||
{
|
|
||||||
_glfwInputError(GLFW_OUT_OF_MEMORY, NULL);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < oi->nmode; i++)
|
for (i = 0; i < oi->nmode; i++)
|
||||||
{
|
{
|
||||||
@ -339,11 +334,6 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found)
|
|||||||
*found = 1;
|
*found = 1;
|
||||||
|
|
||||||
result = (GLFWvidmode*) malloc(sizeof(GLFWvidmode));
|
result = (GLFWvidmode*) malloc(sizeof(GLFWvidmode));
|
||||||
if (!result)
|
|
||||||
{
|
|
||||||
_glfwInputError(GLFW_OUT_OF_MEMORY, NULL);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
result[0].width = DisplayWidth(_glfw.x11.display, _glfw.x11.screen);
|
result[0].width = DisplayWidth(_glfw.x11.display, _glfw.x11.screen);
|
||||||
result[0].height = DisplayHeight(_glfw.x11.display, _glfw.x11.screen);
|
result[0].height = DisplayHeight(_glfw.x11.display, _glfw.x11.screen);
|
||||||
|
Loading…
Reference in New Issue
Block a user