What is Dynamic memory allocation?
Obtaining memory of the needed size while a program is running, and releasing it when it is no longer used. In C, malloc(size) allocates it and returns the address of its start, and free(address) releases it. calloc returns a zero-initialized region and realloc returns a resized one. On failure, NULL is returned, so the result must be checked. The region lies in the heap and survives function returns until it is released. On small microcontrollers it is often avoided because of fragmentation and allocation times that are hard to predict.
Japanese name: 動的メモリ確保
Dynamic memory allocation appears in 7 practice questions across 4 topics, including C Programming Basics, Linkers, Loaders & Executables, Embedded Systems & Firmware.
Field: C Programming Basics