fxlibc/src/libc/stdlib/calloc.c

15 lines
260 B
C

#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, size);
return mem;
}