Skip to content

Instantly share code, notes, and snippets.

@stefafafan
Created October 12, 2013 04:00
Show Gist options
  • Save stefafafan/6945657 to your computer and use it in GitHub Desktop.
Save stefafafan/6945657 to your computer and use it in GitHub Desktop.
calloc implementation
void *calloc(size_t nmemb, size_t size)
{
char *p;
// If either is zero just return NULL.
if (nmemb == 0 || size == 0)
{
return NULL;
}
// Malloc the area and zero it out.
else
{
p = malloc(nmemb * size);
bzero(p, nmemb * size);
return p;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment