Use memset(3) on calloc(3)
This commit is contained in:
parent
bea2c98a06
commit
7de5b52faa
|
@ -115,14 +115,9 @@ malloc_keep_finding:
|
||||||
void *calloc(size_t number, size_t size)
|
void *calloc(size_t number, size_t size)
|
||||||
{
|
{
|
||||||
void *ptr = malloc(number * size);
|
void *ptr = malloc(number * size);
|
||||||
unsigned char *cptr = (unsigned char*)ptr;
|
|
||||||
int x;
|
|
||||||
|
|
||||||
if(ptr == NULL)
|
if (ptr)
|
||||||
ptr = NULL;
|
memset(ptr, 0, number * size);
|
||||||
|
|
||||||
for(x = 0; x < (number * size); x++)
|
|
||||||
cptr[x] = 0;
|
|
||||||
|
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue