void *calloc(size_t nmemb, size_t size); According to the library documentation, The calloc function allocates memory for an array of nmemb elements of size each. The
void *calloc(size_t nmemb, size_t size); According to the library documentation, The calloc function allocates memory for an array of nmemb elements of size each. The memory is set to zero. If nmemb or size is zero, then calloc returns NULL. Write an implementation of calloc that performs the allocation by a call to malloc and sets the memory to zero using memset. Your code should not have any vulnerabilities due to arithmetic overflow, and it should work correctly regardless of the number of bits used to represent data of type size t. As a reference, functions malloc and memset have the following declarations: void *malloc(size_t size); void *memset(void *s, int c, size_t n); Note: I do not want to use the #include
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Solutions CODE include include include using namespace std ...See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started