Use memset(3) on calloc(3)

This commit is contained in:
Xavier Del Campo Romero 2021-10-24 02:22:56 +02:00
parent bea2c98a06
commit 7de5b52faa
1 changed files with 2 additions and 7 deletions

View File

@ -115,14 +115,9 @@ malloc_keep_finding:
void *calloc(size_t number, size_t size)
{
void *ptr = malloc(number * size);
unsigned char *cptr = (unsigned char*)ptr;
int x;
if(ptr == NULL)
ptr = NULL;
for(x = 0; x < (number * size); x++)
cptr[x] = 0;
if (ptr)
memset(ptr, 0, number * size);
return ptr;
}