![]() |
CITS2002 Systems Programming |
next → | ![]() |
![]() |
||||
Dynamic data structuresInitially, we focused on scalar and array variables, whose size is known at compile-time.More recently, we've focused on arrays of values, whose required size was only known at run-time. In the case of dynamic arrays we've used C11 functions such as:
malloc(), calloc(), realloc(), and free()
to manage the required storage for us. An extension to this idea is the use of dynamic data structures - collections of data whose required size is not known until run-time. Again, we'll use C11's standard memory allocation functions whenever we require more memory. However, unlike our use of realloc() to grow (or shrink) a single data structure (there, an array), we'll see two significant differences:
To implement these ideas in C11, we'll develop data structures that contain pointers to other data structures. All code examples in this lecture are available from here: examples.zip
CITS2002 Systems Programming, Lecture 19, p1, 3rd October 2023.
|