The malloc() function allocates size bytes and returns a pointer to the allocated memory. The memory is not initialized. If size is 0, then malloc() returns either NULL, or a unique pointer value that can later be successfully passed to free(). The free() function frees the memory space pointed to by ptr, which must have been returned by a previous call to malloc(), cal‐ loc(), or realloc(). Otherwise, or if free(ptr) has already been called before, undefined behavior occurs. If ptr is NULL, no op‐ eration is performed. The calloc() function allocates memory for an array of nmemb ele‐ ments of size bytes each and returns a pointer to the allocated memory. The memory is set to zero. If nmemb or size is 0, then calloc() returns either NULL, or a unique pointer value that can later be successfully passed to free(). If the multiplication of nmemb and size would result in integer overflow, then calloc() re‐ turns an error. By contrast, an integer overflow would not be de‐ tected in the following call to malloc(), with the result that an incorrectly sized block of memory would be allocated: malloc(nmemb * size);