|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
void *calloc(size_t nmemb, size_t size)
|
|
{
|
|
unsigned int total_size;
|
|
|
|
if(__builtin_umul_overflow(nmemb, size, &total_size))
|
|
return NULL;
|
|
|
|
void *mem = malloc(total_size);
|
|
if(mem) memset(mem, 0, total_size);
|
|
return mem;
|
|
}
|