Embed presentation
Download to read offline


The document discusses dynamic memory allocation in C and some of the challenges that can arise. Specifically, it notes that malloc(1) will not return a 1 byte block due to overhead in allocation structures. This overhead includes space for the size field and a pointer to the next free block. The document also provides an example of undefined behavior that can occur when freeing a pointer that is later accessed, and offers a solution using a temporary variable. Overall, the document outlines the basics of dynamic memory allocation and some issues programmers need to be aware of.
