#include <libc.h>
void* malloc(long size)
void free(void *ptr)
void* realloc(void *ptr, long size)
void* calloc(long nelem, long elsize)
The argument to free is a pointer to a block previously allocated by malloc ; this space is made available for further allocation. It is legal to free a null pointer; the effect is a no-op.
Realloc changes the size of the block pointed to by ptr to size bytes and returns a pointer to the (possibly moved) block. The contents will be unchanged up to the lesser of the new and old sizes. The call "realloc(0, size) means the same as .LR malloc(size) .
Calloc allocates space for an array of nelem elements of size elsize . The space is initialized to zeros. Free frees such a block.
User errors can corrupt the storage arena. The most common gaffes are (1) freeing an already freed block, (2) storing beyond the bounds of an allocated block, and (3) freeing data that was not obtained from the allocator. When malloc and free detect such corruption, they abort.