The
malloc() function allocates
size bytes of uninitialized memory. The allocated space is suitably aligned (after possible pointer coercion) for storage of any type of object.
The
calloc() function allocates space for
number objects, each
size bytes in length. The result is identical to calling
malloc() with an argument of “number * size”, with the exception that the allocated memory is explicitly initialized to zero bytes.
The
realloc() function changes the size of the previously allocated memory referenced by
ptr to
size bytes. The contents of the memory are unchanged up to the lesser of the new and old sizes. If the new size is larger, the value of the newly allocated portion of the memory is undefined. Upon success, the memory referenced by
ptr is freed and a pointer to the newly allocated memory is returned. Note that
realloc() may move the memory allocation, resulting in a different return value than
ptr. If
ptr is
NULL, the
realloc() function behaves identically to
malloc() for the specified size.
The
free() function causes the allocated memory referenced by
ptr to be made available for future allocations. If
ptr is
NULL, no action occurs.