共有 1 篇文章
Data Structure Alignment
2023-02-27 - 2024-09-15
C
The CPU in modern computer hardware performs reads and writes to memory most efficiently when the data is naturally aligned, which generally means that the data’s memory address is a multiple of the data size. For instance, in a 32-bit architecture, the data may be aligned if the data is stored in four consecutive bytes and the first byte lies on a 4-byte boundary. If the highest and lowest bytes in a datum are not within the same memory word the computer must split the datum access into multiple memory accesses.