1#include <stdlib.h>2#include <string.h>3#include <stdint.h>45#undef calloc67void *8calloc(size_t nmemb, size_t size)9{10 size_t nbytes;11 void *mem;1213 if (!nmemb || !size || nmemb > SIZE_MAX/size)14 return NULL;1516 nbytes = nmemb * size;17 if ((mem = malloc(nbytes)) == NULL)18 return NULL;19 return memset(mem, 0, nbytes);20}