Memory Management Functions

Top  Previous  Next

Building complex, dynamically-changing data structures requires a special kind of variable storage. Variables that are static or extern are allocated when a program is written and are therefore not flexible. On the other hand, auto or register variables disappear when the function which created them returns, and do not persist for other functions to access.

 

The storage class that allows the most flexible allocation is generally referred to as heap storage. In C, heap storage is allocated by calling a library function and remains allocated until it is explicitly released.

 


calloc

allocates and clears an area of memory


free

deallocates allocated space


malloc

allocates the specified number of contiguous octets of memory


memalign

allocate a memory-aligned area


realloc

changes the size of an allocated area