From 26e8fde8fbaa06da6a78458b431f4fdd8757d40b Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Mon, 11 Mar 2013 21:30:01 +0100 Subject: [PATCH] Assume malloc works. --- src/win32_monitor.c | 18 +----------------- src/x11_joystick.c | 16 ---------------- src/x11_monitor.c | 10 ---------- 3 files changed, 1 insertion(+), 43 deletions(-) diff --git a/src/win32_monitor.c b/src/win32_monitor.c index 3e4e83b1..605c2acf 100644 --- a/src/win32_monitor.c +++ b/src/win32_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; diff --git a/src/x11_joystick.c b/src/x11_joystick.c index 12581660..2c711134 100644 --- a/src/x11_joystick.c +++ b/src/x11_joystick.c @@ -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__ diff --git a/src/x11_monitor.c b/src/x11_monitor.c index 05f4583f..462f066f 100644 --- a/src/x11_monitor.c +++ b/src/x11_monitor.c @@ -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);