Use calloc directly instead of combining malloc and ZeroMemory
This commit is contained in:
parent
1763e8a2ba
commit
5ebd79745d
|
@ -7404,7 +7404,7 @@ char *LoadFile (const char *fileName, DWORD *size)
|
|||
return NULL;
|
||||
|
||||
*size = GetFileSize (h, NULL);
|
||||
buf = (char *) malloc (*size + 1);
|
||||
buf = (char *) calloc (*size + 1, 1);
|
||||
|
||||
if (buf == NULL)
|
||||
{
|
||||
|
@ -7412,8 +7412,6 @@ char *LoadFile (const char *fileName, DWORD *size)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
ZeroMemory (buf, *size + 1);
|
||||
|
||||
if (!ReadFile (h, buf, *size, size, NULL))
|
||||
{
|
||||
free (buf);
|
||||
|
@ -7444,18 +7442,15 @@ char *LoadFileBlock (char *fileName, __int64 fileOffset, size_t count)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
buf = (char *) malloc (count);
|
||||
buf = (char *) calloc (count, 1);
|
||||
|
||||
if (buf == NULL)
|
||||
{
|
||||
CloseHandle (h);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ZeroMemory (buf, count);
|
||||
|
||||
if (buf != NULL)
|
||||
ReadFile (h, buf, count, &bytesRead, NULL);
|
||||
ReadFile (h, buf, count, &bytesRead, NULL);
|
||||
|
||||
CloseHandle (h);
|
||||
|
||||
|
|
Loading…
Reference in New Issue