Contents    Page-10    Prev    Next    Page+10    Index   

Alignment and Padding

Certain items must be allocated at restricted locations; e.g., a floating point number must be allocated at a word (4-byte or 8-byte) boundary. This is called storage alignment.

In such cases, next is advanced to the next available boundary if needed, and the intervening storage is wasted; this is called padding.

To pad to a boundary of size m , perform:


   wordaddress(next, m)
      = ( (next + m - 1) / m) * m
using truncating integer arithmetic.

For records, a compaction algorithm could be used to minimize wasted storage.