Chapter 22: | How To Create New Structure Objects at Run Time |
Ordinarily, whenever you define a global variable, the C compiler
allocates the memory required to hold an object corresponding to the
variable's type, be it a built-in type, such as int
, or a
user-defined structure, such as trade
. In this chapter, you learn
about an alternative whereby C allocates only a small amount of memory
for a pointer at compile time, deferring until run time the
allocation of memory for an object.
In the hardcopy version of this book, you learn that run-time allocation enables you to reduce the memory consumed by your program when the number of objects that your program encounters is smaller than your worst-case estimate of that number.