mirror of
https://github.com/glfw/glfw.git
synced 2024-11-10 00:51:47 +00:00
Removed superflous casts of allocated memory.
This commit is contained in:
parent
d7512f529c
commit
7a03ca8dbc
@ -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++)
|
||||
{
|
||||
|
@ -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)
|
||||
|
@ -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++)
|
||||
|
@ -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++)
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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++)
|
||||
|
@ -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;
|
||||
|
@ -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++)
|
||||
|
@ -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))
|
||||
{
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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__
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user