Created
October 12, 2013 04:00
-
-
Save stefafafan/6945657 to your computer and use it in GitHub Desktop.
calloc implementation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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