mirror of
https://github.com/glfw/glfw.git
synced 2024-11-10 00:51:47 +00:00
Replaced all uses of malloc with calloc.
This commit is contained in:
parent
1947557eb1
commit
209a470a5f
@ -43,7 +43,7 @@
|
||||
void _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
|
||||
{
|
||||
uint32_t i, size = CGDisplayGammaTableCapacity(monitor->ns.displayID);
|
||||
CGGammaValue* values = (CGGammaValue*) malloc(size * 3 * sizeof(CGGammaValue));
|
||||
CGGammaValue* values = (CGGammaValue*) 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*) malloc(ramp->size * 3 * sizeof(CGGammaValue));
|
||||
CGGammaValue* values = (CGGammaValue*) 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*) malloc(sizeof(_GLFWjoyelement));
|
||||
_GLFWjoyelement* element = (_GLFWjoyelement*) calloc(1, sizeof(_GLFWjoyelement));
|
||||
|
||||
CFArrayAppendValue(elementsArray, element);
|
||||
|
||||
|
@ -58,7 +58,7 @@ static const char* getDisplayName(CGDirectDisplayID displayID)
|
||||
|
||||
size = CFStringGetMaximumSizeForEncoding(CFStringGetLength(value),
|
||||
kCFStringEncodingUTF8);
|
||||
name = (char*) malloc(size + 1);
|
||||
name = (char*) calloc(size + 1, sizeof(char));
|
||||
CFStringGetCString(value, name, size, kCFStringEncodingUTF8);
|
||||
|
||||
CFRelease(info);
|
||||
@ -341,7 +341,7 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found)
|
||||
modes = CGDisplayCopyAllDisplayModes(monitor->ns.displayID, NULL);
|
||||
count = CFArrayGetCount(modes);
|
||||
|
||||
result = (GLFWvidmode*) malloc(sizeof(GLFWvidmode) * count);
|
||||
result = (GLFWvidmode*) calloc(count, sizeof(GLFWvidmode));
|
||||
*found = 0;
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
|
@ -44,9 +44,9 @@
|
||||
|
||||
void _glfwAllocGammaRamp(GLFWgammaramp* ramp, unsigned int size)
|
||||
{
|
||||
ramp->red = (unsigned short*) malloc(size * sizeof(unsigned short));
|
||||
ramp->green = (unsigned short*) malloc(size * sizeof(unsigned short));
|
||||
ramp->blue = (unsigned short*) malloc(size * sizeof(unsigned short));
|
||||
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->size = size;
|
||||
}
|
||||
|
||||
|
@ -146,7 +146,7 @@ WCHAR* _glfwCreateWideStringFromUTF8(const char* source)
|
||||
if (!length)
|
||||
return NULL;
|
||||
|
||||
target = (WCHAR*) malloc(sizeof(WCHAR) * (length + 1));
|
||||
target = (WCHAR*) 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*) malloc(length + 1);
|
||||
target = (char*) calloc(length + 1, sizeof(char));
|
||||
|
||||
if (!WideCharToMultiByte(CP_UTF8, 0, source, -1, target, length + 1, NULL, NULL))
|
||||
{
|
||||
|
@ -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*) malloc(sizeof(GLFWvidmode) * oi->nmode);
|
||||
result = (GLFWvidmode*) 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*) malloc(sizeof(GLFWvidmode));
|
||||
result = (GLFWvidmode*) 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