Add asserts for public API pointer parameters

This commit is contained in:
Camilla Berglund
2016-01-31 17:56:36 +01:00
parent d0649e6868
commit 0ebdad53e8
4 changed files with 99 additions and 0 deletions
+13
View File
@@ -27,6 +27,7 @@
#include "internal.h"
#include <assert.h>
#include <math.h>
#include <float.h>
#include <string.h>
@@ -293,6 +294,7 @@ void _glfwSplitBPP(int bpp, int* red, int* green, int* blue)
GLFWAPI GLFWmonitor** glfwGetMonitors(int* count)
{
assert(count);
*count = 0;
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
@@ -314,6 +316,7 @@ GLFWAPI GLFWmonitor* glfwGetPrimaryMonitor(void)
GLFWAPI void glfwGetMonitorPos(GLFWmonitor* handle, int* xpos, int* ypos)
{
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
assert(monitor);
if (xpos)
*xpos = 0;
@@ -328,6 +331,7 @@ GLFWAPI void glfwGetMonitorPos(GLFWmonitor* handle, int* xpos, int* ypos)
GLFWAPI void glfwGetMonitorPhysicalSize(GLFWmonitor* handle, int* widthMM, int* heightMM)
{
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
assert(monitor);
if (widthMM)
*widthMM = 0;
@@ -345,6 +349,8 @@ GLFWAPI void glfwGetMonitorPhysicalSize(GLFWmonitor* handle, int* widthMM, int*
GLFWAPI const char* glfwGetMonitorName(GLFWmonitor* handle)
{
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
assert(monitor);
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
return monitor->name;
}
@@ -359,7 +365,9 @@ GLFWAPI GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun cbfun)
GLFWAPI const GLFWvidmode* glfwGetVideoModes(GLFWmonitor* handle, int* count)
{
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
assert(monitor);
assert(count);
*count = 0;
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
@@ -374,6 +382,7 @@ GLFWAPI const GLFWvidmode* glfwGetVideoModes(GLFWmonitor* handle, int* count)
GLFWAPI const GLFWvidmode* glfwGetVideoMode(GLFWmonitor* handle)
{
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
assert(monitor);
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
@@ -422,6 +431,7 @@ GLFWAPI void glfwSetGamma(GLFWmonitor* handle, float gamma)
GLFWAPI const GLFWgammaramp* glfwGetGammaRamp(GLFWmonitor* handle)
{
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
assert(monitor);
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
@@ -434,6 +444,9 @@ GLFWAPI const GLFWgammaramp* glfwGetGammaRamp(GLFWmonitor* handle)
GLFWAPI void glfwSetGammaRamp(GLFWmonitor* handle, const GLFWgammaramp* ramp)
{
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
assert(monitor);
assert(ramp);
_GLFW_REQUIRE_INIT();