OC底层_内存对齐探究

define SHIFT_NANO_QUANTUM 4

define NANO_REGIME_QUANTA_SIZE (1 << SHIFT_NANO_QUANTUM) // 16

static MALLOC_INLINE size_t
segregated_size_to_fit(nanozone_t *nanozone, size_t size, size_t *pKey)
{
size_t k, slot_bytes;

if (0 == size) {
    size = NANO_REGIME_QUANTA_SIZE; // Historical behavior
}
k = (size + NANO_REGIME_QUANTA_SIZE - 1) >> SHIFT_NANO_QUANTUM; // round up and shift for number of quanta
slot_bytes = k << SHIFT_NANO_QUANTUM;                           // multiply by power of two quanta size
*pKey = k - 1;                                                  // Zero-based!

return slot_bytes;

}

你可能感兴趣的:(OC底层_内存对齐探究)