ref: 67d90c41c1d5ef13d67cc0a3ce2bd7de1cc53037
dir: /lib/c/calloc.c/
#include <stdlib.h>
#include <string.h>
void *
calloc(size_t nmemb, size_t size)
{
size_t nbytes;
void *mem;
if (!nmemb || !size || nmemb > (size_t)-1/size)
return NULL;
nbytes = nmemb * size;
if ((mem = malloc(nbytes)) == NULL)
return NULL;
return memset(mem, 0, nbytes);
}