The malloc, calloc, and realloc functions are standard C library utilities for dynamic memory management on the heap.
malloc(size) allocates a block of memory of the specified size in bytes and returns a pointer to the beginning of that block. If allocation fails, it returns NULL.
calloc(num_elements, element_size) allocates memory for an array of num_elements, each of element_size bytes. Crucially, it initializes all bits in the allocated memory to zero. It also returns NULL on failure.
realloc(ptr, new_size) resizes a previously allocated memory block pointed to by ptr to new_size bytes. It may move the block to a new location if necessary and returns a pointer to the resized block. If ptr is NULL, it behaves like malloc(new_size). If new_size is 0 and ptr is not NULL, it behaves like free(ptr) and returns NULL.