Boost.Pool: различия между версиями

Содержимое удалено Содержимое добавлено
Строка 470:
Так как pe + i четко определено, тогда в соответствии с Заключением 3, pn + jn также четко определено и имеет правильно выравнивание в соответствии с Утверждением 2 и Заключениями 1 and 2.
 
==== nextUse of the Theorem ====
The proof above covers alignment requirements for cutting chunks out of a block. The implementation uses actual object sizes of:
{{В планах}}
 
The requested object size (requested_size); this is the size of chunks requested by the user
void* (pointer to void); this is because we interleave our free list through the chunks
size_type; this is because we store the size of the next block within each memory block
Each block also contains a pointer to the next block; but that is stored as a pointer to void and cast when necessary, to simplify alignment requirements to the three types above.
 
Therefore, alloc_size is defined to be the largest of the sizes above, rounded up to be a multiple of all three sizes. This guarantees alignment provided all alignments are powers of two: something that appears to be true on all known platforms.
 
==== A Look at the Memory Block ====
Each memory block consists of three main sections. The first section is the part that chunks are cut out of, and contains the interleaved free list. The second section is the pointer to the next block, and the third section is the size of the next block.
 
Each of these sections may contain padding as necessary to guarantee alignment for each of the next sections. The size of the first section is number_of_chunks * lcm(requested_size, sizeof(void *), sizeof(size_type)); the size of the second section is lcm(sizeof(void *), sizeof(size_type); and the size of the third section is sizeof(size_type).
 
Here's an example memory block, where requested_size == sizeof(void *) == sizeof(size_type) == 4:
 
 
 
To show a visual example of possible padding, here's an example memory block where requested_size == 8 and sizeof(void *) == sizeof(size_type) == 4'''Полужирное начертание'''
 
==== next ====