- int i, mask;
-
- /* Build an alignment mask that can be used for testing
- size % 2*align. If (size | MAX_ALIGNMENT) & mask is non-zero
- then the requested size apparent alignment requirement
- (which is at most MAX_ALIGNMENT) is less or equal than what
- the OBJECT_SIZE bin can guarantee. */
- mask = ~(((unsigned)-1) << ffs (OBJECT_SIZE (order)));
- mask &= 2 * MAX_ALIGNMENT - 1;
-
- /* All objects smaller than the OBJECT_SIZE for this ORDER could go
- into ORDER. Determine the cases for which that is profitable
- and fulfilling the alignment requirements. Stop searching
- once a smaller bin with same or better alignment guarantee is
- found. */
- for (i = OBJECT_SIZE (order); ; --i)
- {
- unsigned int old_sz = OBJECT_SIZE (size_lookup [i]);
- if (!(old_sz & (mask >> 1))
- && old_sz < OBJECT_SIZE (order))
- break;
-
- /* If object of size I are presently using a larger bin, we would
- like to move them to ORDER. However, we can only do that if we
- can be sure they will be properly aligned. They will be properly
- aligned if either the ORDER bin is maximally aligned, or if
- objects of size I cannot be more strictly aligned than the
- alignment of this order. */
- if ((i | MAX_ALIGNMENT) & mask
- && old_sz > OBJECT_SIZE (order))
- size_lookup[i] = order;
- }
- }