liveBook · Manning

Storage instance

As explained in Modern C, Third Edition

A storage instance is a particular occurrence of storage associated with an object declaration or function invocation, especially when recursive calls create separate occurrences.

A storage instance is a particular occurrence of storage associated with an object declaration or function invocation. Recursive calls can create separate instances of the same declared variable, so each call in the recursion hierarchy has its own occurrence. section 13.0

Keep the storage instance distinct from the other layers of a C object:

  • An object combines storage, type, and value; a storage instance identifies the underlying occurrence of storage. section 12.4
  • Object lifetime and identifier visibility depend on how the object is declared, while recursive declarations can produce multiple storage instances. section 13.0
  • Dynamic allocation creates storage instances initially seen only as byte arrays; they acquire an object type when a value is stored. section 13.0

Recursive calls and allocated storage

Imagine a recursive function whose declaration includes a variable. Each active call has its own storage instance for that variable, rather than sharing one occurrence. Separately, dynamically allocated storage begins as a byte array without object interpretation and becomes associated with an object when a value is stored. section 13.0

How Modern C, Third Edition covers it

How deep it goes
Explains the distinction from objects, lifetimes, visibility, and types, but defers detailed duration and initialization rules.
Examples
Uses recursive function calls and dynamically allocated byte arrays to illustrate separate occurrences and initially untyped storage.
What it assumes
Assumes familiarity with C objects, declarations, function calls, and pointers while distinguishing storage from type and value.
What you can do after
Evaluate whether multiple declarations or allocations represent distinct storage occurrences rather than a single shared object.
How it connects
Connects storage instances with object lifetime, identifier visibility, storage duration, dynamic allocation, object representation, and void pointers.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Modern C, Third Edition. The section links point to the parts of the book it draws on.