pub unsafe fn realloc(
        &mut self,
        pointer: Pointer,
        old: usize,
        new: usize,
    ) -> Pointer {
        assert!(pointer.is_owned());

        if new > old {
            // try allocation continiously
            let tail = pointer.add(old as u64);
            if self.free.is_free(tail, new - old) {
                // increase the size of the current allocation
                self.free.mark_smaller(tail.to_idx(), new - old);
                return pointer;
            }

            // TODO: free before reallocation might open up space before?
            // reallocate new larger allocation, copy over data.
            let new_pointer = self.alloc(new);
            for slot in 0..old {
                self.data.swap(
                    new_pointer.to_idx().to_usize() + slot,
                    pointer.to_idx().to_usize() + slot,
                );
            }
            // and free old small allocation
            self.free(pointer, old);
            return new_pointer;
        } else if old > new {
            // free back half of allocation
            self.free(pointer.add(new as u64), old - new);
        }

        // they're equal, so do nothing
        return pointer;
    }
Reallocates an allocation to a larger size
Tries to reallocate in place, but moves the allocation if needed.

# Safety
All previously allocated data will be present at the start of the new
allocation. For example, if you have an allocation `*x = ABC` of len
3, and reallocate to len 5, the new allocation will be `*x = ABC__`.

Likewise, if you decrease the size of the allocation, data will be
truncated. So `*x = ABC` of len 3 reallocated to len 1 would be `*x
= A`.

Like when using `Heap::alloc`, this call must be immediately be followed
by a call to [`Heap::write`] to fill the uninitialized portion of
the new array.
passerine-qualm/src/heap/mod.rs