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

Содержимое удалено Содержимое добавлено
Строка 470:
Так как pe + i четко определено, тогда в соответствии с Заключением 3, pn + jn также четко определено и имеет правильно выравнивание в соответствии с Утверждением 2 и Заключениями 1 and 2.
 
==== UseПрименение of the TheoremТеоремы ====
The proof above covers alignment requirements for cutting chunks out of a block. The implementation uses actual object sizes of:
 
Запрошенный размер объекта (requested_size); это размер памяти запрошенный пользователем
The requested object size (requested_size); this is the size of chunks requested by the user
void* (указатель на void); нужен для размещения списка свободных блоков
void* (pointer to void); this is because we interleave our free list through the chunks
size_type; мы храним размер следующего блока в каждом блоке
size_type; this is because we store the size of the next block within each memory block
Также каждый блок содержит указатель на следующий блок; он хранится как указатель на void и приводится к нужному типу при необходимости, для упрощения требований к выравниванию.
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.
 
Следовательно, alloc_size является наибольшим размеров из указанных выше, округленный, чтобы бы быть кратным всех трем размерам. Это гарантирует выравнивание при условии, что выравнивание является степеньь двух: что выполняется на всех известных платформах.
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 ====