© Thomas Mailund 2021
T. MailundPointers in C Programminghttps://doi.org/10.1007/978-1-4842-6927-5_14

14. Generic Lists and Trees

Thomas Mailund1  
(1)
Aarhus N, Denmark
 

We now return to lists and trees and consider what it will take to make them generic the way we make generic dynamic arrays in Chapter 10. The techniques we used there, working with void pointers or generating code using macros, will also work with lists and trees, but we will take a different approach.

With lists and trees, we are not working with contiguously allocated chunks of memory, so in principle, links and nodes can have any size. A generic data structure needs to know about the bits that define a link or a node, but if we allocate memory to store additional data alongside ...

Get Pointers in C Programming: A Modern Approach to Memory Management, Recursive Data Structures, Strings, and Arrays 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.