From 7a03ca8dbc8a5550d63ecad49a727c528300e769 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Thu, 4 Jul 2013 14:54:07 +0200 Subject: [PATCH] Removed superflous casts of allocated memory. --- src/cocoa_gamma.c | 4 ++-- src/cocoa_joystick.m | 8 ++++---- src/cocoa_monitor.m | 8 ++++---- src/egl_context.c | 4 ++-- src/gamma.c | 6 +++--- src/glx_context.c | 2 +- src/monitor.c | 2 +- src/wgl_context.c | 2 +- src/win32_init.c | 4 ++-- src/window.c | 2 +- src/x11_joystick.c | 4 ++-- src/x11_monitor.c | 8 ++++---- 12 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/cocoa_gamma.c b/src/cocoa_gamma.c index d4a25f1d..f69d66fe 100644 --- a/src/cocoa_gamma.c +++ b/src/cocoa_gamma.c @@ -43,7 +43,7 @@ void _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp) { uint32_t i, size = CGDisplayGammaTableCapacity(monitor->ns.displayID); - CGGammaValue* values = (CGGammaValue*) calloc(size * 3, sizeof(CGGammaValue)); + CGGammaValue* values = calloc(size * 3, sizeof(CGGammaValue)); CGGetDisplayTransferByTable(monitor->ns.displayID, size, @@ -67,7 +67,7 @@ void _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp) void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp) { int i; - CGGammaValue* values = (CGGammaValue*) calloc(ramp->size * 3, sizeof(CGGammaValue)); + CGGammaValue* values = calloc(ramp->size * 3, sizeof(CGGammaValue)); for (i = 0; i < ramp->size; i++) { diff --git a/src/cocoa_joystick.m b/src/cocoa_joystick.m index c4804309..3d84c839 100644 --- a/src/cocoa_joystick.m +++ b/src/cocoa_joystick.m @@ -113,7 +113,7 @@ static void addJoystickElement(_GLFWjoy* joystick, CFTypeRef elementRef) { long number; CFTypeRef numberRef; - _GLFWjoyelement* element = (_GLFWjoyelement*) calloc(1, sizeof(_GLFWjoyelement)); + _GLFWjoyelement* element = calloc(1, sizeof(_GLFWjoyelement)); CFArrayAppendValue(elementsArray, element); @@ -427,10 +427,10 @@ void _glfwInitJoysticks(void) CFRelease(valueRef); } - joystick->axes = (float*) calloc(CFArrayGetCount(joystick->axisElements), + joystick->axes = calloc(CFArrayGetCount(joystick->axisElements), sizeof(float)); - joystick->buttons = (unsigned char*) calloc(CFArrayGetCount(joystick->buttonElements) + - CFArrayGetCount(joystick->hatElements) * 4, 1); + joystick->buttons = calloc(CFArrayGetCount(joystick->buttonElements) + + CFArrayGetCount(joystick->hatElements) * 4, 1); joy++; if (joy > GLFW_JOYSTICK_LAST) diff --git a/src/cocoa_monitor.m b/src/cocoa_monitor.m index 79e22d3b..4f4526ba 100644 --- a/src/cocoa_monitor.m +++ b/src/cocoa_monitor.m @@ -58,7 +58,7 @@ static const char* getDisplayName(CGDirectDisplayID displayID) size = CFStringGetMaximumSizeForEncoding(CFStringGetLength(value), kCFStringEncodingUTF8); - name = (char*) calloc(size + 1, sizeof(char)); + name = calloc(size + 1, sizeof(char)); CFStringGetCString(value, name, size, kCFStringEncodingUTF8); CFRelease(info); @@ -253,8 +253,8 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* count) CGGetActiveDisplayList(0, NULL, &monitorCount); - displays = (CGDirectDisplayID*) calloc(monitorCount, sizeof(CGDirectDisplayID)); - monitors = (_GLFWmonitor**) calloc(monitorCount, sizeof(_GLFWmonitor*)); + displays = calloc(monitorCount, sizeof(CGDirectDisplayID)); + monitors = calloc(monitorCount, sizeof(_GLFWmonitor*)); CGGetActiveDisplayList(monitorCount, displays, &monitorCount); @@ -341,7 +341,7 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found) modes = CGDisplayCopyAllDisplayModes(monitor->ns.displayID, NULL); count = CFArrayGetCount(modes); - result = (GLFWvidmode*) calloc(count, sizeof(GLFWvidmode)); + result = calloc(count, sizeof(GLFWvidmode)); *found = 0; for (i = 0; i < count; i++) diff --git a/src/egl_context.c b/src/egl_context.c index 8b30934a..f136b332 100644 --- a/src/egl_context.c +++ b/src/egl_context.c @@ -127,10 +127,10 @@ static GLboolean chooseFBConfigs(const _GLFWwndconfig* wndconfig, return GL_FALSE; } - nativeConfigs = (EGLConfig*) calloc(nativeCount, sizeof(EGLConfig)); + nativeConfigs = calloc(nativeCount, sizeof(EGLConfig)); eglGetConfigs(_glfw.egl.display, nativeConfigs, nativeCount, &nativeCount); - usableConfigs = (_GLFWfbconfig*) calloc(nativeCount, sizeof(_GLFWfbconfig)); + usableConfigs = calloc(nativeCount, sizeof(_GLFWfbconfig)); usableCount = 0; for (i = 0; i < nativeCount; i++) diff --git a/src/gamma.c b/src/gamma.c index 24745c14..c538b590 100644 --- a/src/gamma.c +++ b/src/gamma.c @@ -44,9 +44,9 @@ void _glfwAllocGammaArrays(GLFWgammaramp* ramp, unsigned int size) { - ramp->red = (unsigned short*) calloc(size, sizeof(unsigned short)); - ramp->green = (unsigned short*) calloc(size, sizeof(unsigned short)); - ramp->blue = (unsigned short*) calloc(size, sizeof(unsigned short)); + ramp->red = calloc(size, sizeof(unsigned short)); + ramp->green = calloc(size, sizeof(unsigned short)); + ramp->blue = calloc(size, sizeof(unsigned short)); ramp->size = size; } diff --git a/src/glx_context.c b/src/glx_context.c index fc93c2b0..d8989dff 100644 --- a/src/glx_context.c +++ b/src/glx_context.c @@ -111,7 +111,7 @@ static GLboolean chooseFBConfig(const _GLFWfbconfig* desired, GLXFBConfig* resul return GL_FALSE; } - usableConfigs = (_GLFWfbconfig*) calloc(nativeCount, sizeof(_GLFWfbconfig)); + usableConfigs = calloc(nativeCount, sizeof(_GLFWfbconfig)); usableCount = 0; for (i = 0; i < nativeCount; i++) diff --git a/src/monitor.c b/src/monitor.c index 2107e070..3c143564 100644 --- a/src/monitor.c +++ b/src/monitor.c @@ -180,7 +180,7 @@ void _glfwInputMonitorChange(void) _GLFWmonitor* _glfwCreateMonitor(const char* name, int widthMM, int heightMM) { - _GLFWmonitor* monitor = (_GLFWmonitor*) calloc(1, sizeof(_GLFWmonitor)); + _GLFWmonitor* monitor = calloc(1, sizeof(_GLFWmonitor)); monitor->name = strdup(name); monitor->widthMM = widthMM; monitor->heightMM = heightMM; diff --git a/src/wgl_context.c b/src/wgl_context.c index 943ff88e..4c009124 100644 --- a/src/wgl_context.c +++ b/src/wgl_context.c @@ -172,7 +172,7 @@ static GLboolean choosePixelFormat(_GLFWwindow* window, return GL_FALSE; } - usableConfigs = (_GLFWfbconfig*) calloc(nativeCount, sizeof(_GLFWfbconfig)); + usableConfigs = calloc(nativeCount, sizeof(_GLFWfbconfig)); usableCount = 0; for (i = 0; i < nativeCount; i++) diff --git a/src/win32_init.c b/src/win32_init.c index 188522df..d7abeca6 100644 --- a/src/win32_init.c +++ b/src/win32_init.c @@ -146,7 +146,7 @@ WCHAR* _glfwCreateWideStringFromUTF8(const char* source) if (!length) return NULL; - target = (WCHAR*) calloc(length + 1, sizeof(WCHAR)); + target = calloc(length + 1, sizeof(WCHAR)); if (!MultiByteToWideChar(CP_UTF8, 0, source, -1, target, length + 1)) { @@ -168,7 +168,7 @@ char* _glfwCreateUTF8FromWideString(const WCHAR* source) if (!length) return NULL; - target = (char*) calloc(length + 1, sizeof(char)); + target = calloc(length + 1, sizeof(char)); if (!WideCharToMultiByte(CP_UTF8, 0, source, -1, target, length + 1, NULL, NULL)) { diff --git a/src/window.c b/src/window.c index 00f7a12a..d5a8ef7e 100644 --- a/src/window.c +++ b/src/window.c @@ -198,7 +198,7 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height, if (!_glfwIsValidContextConfig(&wndconfig)) return GL_FALSE; - window = (_GLFWwindow*) calloc(1, sizeof(_GLFWwindow)); + window = calloc(1, sizeof(_GLFWwindow)); window->next = _glfw.windowListHead; _glfw.windowListHead = window; diff --git a/src/x11_joystick.c b/src/x11_joystick.c index 49164d79..37bd56f2 100644 --- a/src/x11_joystick.c +++ b/src/x11_joystick.c @@ -80,8 +80,8 @@ static int openJoystickDevice(int joy, const char* path) ioctl(fd, JSIOCGBUTTONS, &buttonCount); _glfw.x11.joystick[joy].buttonCount = (int) buttonCount; - _glfw.x11.joystick[joy].axes = (float*) calloc(axisCount, sizeof(float)); - _glfw.x11.joystick[joy].buttons = (unsigned char*) calloc(buttonCount, 1); + _glfw.x11.joystick[joy].axes = calloc(axisCount, sizeof(float)); + _glfw.x11.joystick[joy].buttons = calloc(buttonCount, 1); _glfw.x11.joystick[joy].present = GL_TRUE; #endif // __linux__ diff --git a/src/x11_monitor.c b/src/x11_monitor.c index c6549ced..437a94e9 100644 --- a/src/x11_monitor.c +++ b/src/x11_monitor.c @@ -177,7 +177,7 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* count) sr = XRRGetScreenResources(_glfw.x11.display, _glfw.x11.root); primary = XRRGetOutputPrimary(_glfw.x11.display, _glfw.x11.root); - monitors = (_GLFWmonitor**) calloc(sr->ncrtc, sizeof(_GLFWmonitor*)); + monitors = calloc(sr->ncrtc, sizeof(_GLFWmonitor*)); for (i = 0; i < sr->ncrtc; i++) { @@ -247,7 +247,7 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* count) } else { - monitors = (_GLFWmonitor**) calloc(1, sizeof(_GLFWmonitor*)); + monitors = calloc(1, sizeof(_GLFWmonitor*)); monitors[0] = _glfwCreateMonitor("Display", DisplayWidthMM(_glfw.x11.display, _glfw.x11.screen), @@ -312,7 +312,7 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found) sr = XRRGetScreenResources(_glfw.x11.display, _glfw.x11.root); oi = XRRGetOutputInfo(_glfw.x11.display, sr, monitor->x11.output); - result = (GLFWvidmode*) calloc(oi->nmode, sizeof(GLFWvidmode)); + result = calloc(oi->nmode, sizeof(GLFWvidmode)); for (i = 0; i < oi->nmode; i++) { @@ -354,7 +354,7 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found) { *found = 1; - result = (GLFWvidmode*) calloc(1, sizeof(GLFWvidmode)); + result = calloc(1, sizeof(GLFWvidmode)); result[0].width = DisplayWidth(_glfw.x11.display, _glfw.x11.screen); result[0].height = DisplayHeight(_glfw.x11.display, _glfw.x11.screen);