/// Given a `block` with the specified `order`, find the "buddy" block,
/// that is, the other half of the block we originally split it from,
/// and also the block we could potentially merge it with.
Given a `block` with the specified `order`, find the "buddy" block,
that is, the other half of the block we originally split it from,
and also the block we could potentially merge it with.
Given a ` block ` with the specified ` order ` find the " buddy " block that is the other half of the block we originally split it from and also the block we could potentially merge it with .
fn buddy(&self, order: usize, block: *mut u8) -> Option<*mut u8> {
        assert!(block >= self.heap_base);
        let relative = unsafe { block.offset_from(self.heap_base) } as usize;
        let size = self.order_size(order);
        if size >= self.heap_size {
            // The main heap itself does not have a budy.
            None
        } else {
            // Fun: We can find our buddy by xoring the right bit in our
            // offset from the base of the heap.
            Some(unsafe { self.heap_base.add(relative ^ size) })
        }
    }
fn buddy ( & self , order : usize , block : * mut u8 ) -> Option < * mut u8 > { assert ! ( block self heap_base ) ; let relative = unsafe { block . offset_from ( self . heap_base ) } as usize ; let size = self . order_size ( order ) ; if size >= self . heap_size { // The main heap itself does not have a budy. None } else { // Fun: We can find our buddy by xoring the right bit in our // offset from the base of the heap. Some ( unsafe { self . heap_base . add ( relative ^ size ) } ) } }
Given a `block` with the specified `order`, find the "buddy" block,
that is, the other half of the block we originally split it from,
and also the block we could potentially merge it with.
Given a ` block ` with the specified ` order ` find the " buddy " block that is the other half of the block we originally split it from and also the block we could potentially merge it with .
&self
order
usize
block
*mut u8