Browse Source

Removed superflous casts of allocated memory.

Camilla Berglund 12 years ago
parent
commit
7a03ca8dbc
12 changed files with 27 additions and 27 deletions
  1. 2 2
      src/cocoa_gamma.c
  2. 4 4
      src/cocoa_joystick.m
  3. 4 4
      src/cocoa_monitor.m
  4. 2 2
      src/egl_context.c
  5. 3 3
      src/gamma.c
  6. 1 1
      src/glx_context.c
  7. 1 1
      src/monitor.c
  8. 1 1
      src/wgl_context.c
  9. 2 2
      src/win32_init.c
  10. 1 1
      src/window.c
  11. 2 2
      src/x11_joystick.c
  12. 4 4
      src/x11_monitor.c

+ 2 - 2
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++)
     {

+ 4 - 4
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)

+ 4 - 4
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++)

+ 2 - 2
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++)

+ 3 - 3
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;
 }
 

+ 1 - 1
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++)

+ 1 - 1
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;

+ 1 - 1
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++)

+ 2 - 2
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))
     {

+ 1 - 1
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;
 

+ 2 - 2
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__

+ 4 - 4
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);