C Dynamic Allocation Functions

This tutorial describes C's dynamic allocation functions. At their core are malloc() and free(). Each time malloc() is called, a portion of the remaining free memory is allocated. Each time free() is called, memory is returned to the system. The region of free memory from which memory is allocated is called the heap.

The prototypes for the dynamic allocation functions are in <stdlib.h>.

Standard C defines four dynamic allocation functions that all compilers will supply: calloc(), free(), malloc(), and realloc(). However, your compiler will almost certainly contain several nonstandard variants on these functions to accommodate various options and environmental differences. For example, special allocation functions are supplied by compilers that produce code for the segmented memory model of the 8086. You will want to refer to your compiler's documentation for details and descriptions of additional allocation functions.

C Online Test

« C Tutorial Next Function »

Like/Share Us on Facebook 😋