From b29fbc82c2b99c3c20b6828234e0d4a32e683ffe Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Mon, 7 Apr 2014 15:28:32 +0200 Subject: [PATCH] Ensure out arguments are always set. --- src/input.c | 6 +++++- src/monitor.c | 12 ++++++++++++ src/window.c | 28 +++++++++++++++++++++++++++- src/x11_window.c | 9 --------- 4 files changed, 44 insertions(+), 11 deletions(-) diff --git a/src/input.c b/src/input.c index d3da2391..4b52a220 100644 --- a/src/input.c +++ b/src/input.c @@ -319,11 +319,15 @@ GLFWAPI void glfwGetCursorPos(GLFWwindow* handle, double* xpos, double* ypos) { _GLFWwindow* window = (_GLFWwindow*) handle; + if (xpos) + *xpos = 0; + if (ypos) + *ypos = 0; + _GLFW_REQUIRE_INIT(); if (xpos) *xpos = window->cursorPosX; - if (ypos) *ypos = window->cursorPosY; } diff --git a/src/monitor.c b/src/monitor.c index 88fada04..a953cb4b 100644 --- a/src/monitor.c +++ b/src/monitor.c @@ -295,7 +295,14 @@ GLFWAPI GLFWmonitor* glfwGetPrimaryMonitor(void) GLFWAPI void glfwGetMonitorPos(GLFWmonitor* handle, int* xpos, int* ypos) { _GLFWmonitor* monitor = (_GLFWmonitor*) handle; + + if (xpos) + *xpos = 0; + if (ypos) + *ypos = 0; + _GLFW_REQUIRE_INIT(); + _glfwPlatformGetMonitorPos(monitor, xpos, ypos); } @@ -303,6 +310,11 @@ GLFWAPI void glfwGetMonitorPhysicalSize(GLFWmonitor* handle, int* width, int* he { _GLFWmonitor* monitor = (_GLFWmonitor*) handle; + if (width) + *width = 0; + if (height) + height = 0; + _GLFW_REQUIRE_INIT(); if (width) diff --git a/src/window.c b/src/window.c index e9e575e6..b7cc8fae 100644 --- a/src/window.c +++ b/src/window.c @@ -434,6 +434,12 @@ GLFWAPI void glfwSetWindowTitle(GLFWwindow* handle, const char* title) GLFWAPI void glfwGetWindowPos(GLFWwindow* handle, int* xpos, int* ypos) { _GLFWwindow* window = (_GLFWwindow*) handle; + + if (xpos) + *xpos = 0; + if (ypos) + *ypos = 0; + _GLFW_REQUIRE_INIT(); _glfwPlatformGetWindowPos(window, xpos, ypos); } @@ -457,6 +463,12 @@ GLFWAPI void glfwSetWindowPos(GLFWwindow* handle, int xpos, int ypos) GLFWAPI void glfwGetWindowSize(GLFWwindow* handle, int* width, int* height) { _GLFWwindow* window = (_GLFWwindow*) handle; + + if (width) + *width = 0; + if (height) + *height = 0; + _GLFW_REQUIRE_INIT(); _glfwPlatformGetWindowSize(window, width, height); } @@ -483,8 +495,12 @@ GLFWAPI void glfwGetFramebufferSize(GLFWwindow* handle, int* width, int* height) { _GLFWwindow* window = (_GLFWwindow*) handle; - _GLFW_REQUIRE_INIT(); + if (width) + *width = 0; + if (height) + *height = 0; + _GLFW_REQUIRE_INIT(); _glfwPlatformGetFramebufferSize(window, width, height); } @@ -493,6 +509,16 @@ GLFWAPI void glfwGetWindowFrameSize(GLFWwindow* handle, int* right, int* bottom) { _GLFWwindow* window = (_GLFWwindow*) handle; + + if (left) + *left = 0; + if (top) + *top = 0; + if (right) + *right = 0; + if (bottom) + *bottom = 0; + _GLFW_REQUIRE_INIT(); _glfwPlatformGetWindowFrameSize(window, left, top, right, bottom); } diff --git a/src/x11_window.c b/src/x11_window.c index e832cb53..77537a9e 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -1280,15 +1280,6 @@ void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window, { long* extents = NULL; - if (left) - *left = 0; - if (top) - *top = 0; - if (right) - *right = 0; - if (bottom) - *bottom = 0; - if (_glfw.x11.NET_FRAME_EXTENTS == None) return;