Assume malloc works.

master
Camilla Berglund ago%!(EXTRA string=13 years)
parent 51ee3a5c0a
commit 26e8fde8fb
  1. 18
      src/win32_monitor.c
  2. 16
      src/x11_joystick.c
  3. 10
      src/x11_monitor.c

@ -134,11 +134,6 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* count)
size = 4;
monitors = (_GLFWmonitor**) realloc(monitors, sizeof(_GLFWmonitor*) * size);
if (!monitors)
{
// TODO: wat
return NULL;
}
}
ZeroMemory(&display, sizeof(DISPLAY_DEVICE));
@ -250,23 +245,12 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found)
if (*found == count)
{
void* larger;
if (count)
count *= 2;
else
count = 128;
larger = realloc(result, count * sizeof(GLFWvidmode));
if (!larger)
{
free(result);
_glfwInputError(GLFW_OUT_OF_MEMORY, NULL);
return NULL;
}
result = (GLFWvidmode*) larger;
result = (GLFWvidmode*) realloc(result, count * sizeof(GLFWvidmode));
}
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].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);
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;
#endif // __linux__

@ -286,11 +286,6 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found)
oi = XRRGetOutputInfo(_glfw.x11.display, sr, monitor->x11.output);
result = (GLFWvidmode*) malloc(sizeof(GLFWvidmode) * oi->nmode);
if (!result)
{
_glfwInputError(GLFW_OUT_OF_MEMORY, NULL);
return NULL;
}
for (i = 0; i < oi->nmode; i++)
{
@ -339,11 +334,6 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found)
*found = 1;
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].height = DisplayHeight(_glfw.x11.display, _glfw.x11.screen);

Loading…
Cancel
Save