- // The allocation request fits into the current chunk iff:
- //
- // let aligned = align_to(ptr, align);
- // ptr <= aligned && aligned + bytes <= end
- //
- // Except that we work with fixed width integers and need to be careful
- // about potential overflow in the calcuation. If the overflow does
- // happen, then we definitely don't have enough free and need to grow
- // the arena.
- let aligned = ptr.checked_add(align - 1)? & !(align - 1);
- let new_ptr = aligned.checked_add(bytes)?;
- if new_ptr <= end {
- self.ptr.set(new_ptr as *mut u8);
- Some(aligned as *mut u8)