© Mikael Olsson 2019
Mikael OlssonModern C Quick Syntax Referencehttps://doi.org/10.1007/978-1-4842-4288-9_19

19. Memory Management

Mikael Olsson1 
(1)
Hammarland, Länsi-Suomi, Finland
 

In the examples so far, the programs have only had as much memory available as has been declared for the variables at compile time. This is referred to as static allocation. If any additional memory is needed at runtime, it becomes necessary to use dynamic allocation. The C standard library provides several functions for managing dynamically allocated memory, including malloc, free, realloc, and calloc. These functions are found in the stdlib.h header file.

Malloc

The malloc function takes a size in bytes and returns a pointer to a block of free memory of that size. ...

Get Modern C Quick Syntax Reference: A Pocket Guide to the Language, APIs, and Library now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.