Chapter 20
Memory Chunks and Linked Lists
IN THIS CHAPTER
Grabbing a chunk of memory with malloc()
Initializing and allocating memory
Resizing an allocated memory chunk
De-allocating memory
Creating space for a structure
Building a linked list
Editing structures in a linked list
Another reason for having a pointer variable is to hold the address of a freshly allocated chunk of memory. This approach is far better than creating an array and guessing at its size: Memory chunks can be assigned a size on the fly, resized, and banished. You can’t perform such actions with an array — well, not in civilized society.
Dovetailing from memory allocation comes the ultimate thrill ride in the C language amusement park: the linked list. It combines the mystery of structures with the dread of pointers ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access