the old logic would be incorrect if the payload has higher alignment than the ArenaHeader i.e. when there is padding between the ArenaHeader and the Payload
Self::Payload: Sized,
{
TypedArenaPtr(NonNull::new_unchecked(
- ptr.payload_offset().cast_mut().cast::<Self::Payload>(),
+ ptr.get_ptr()
+ .byte_add(Self::header_offset_from_payload())
+ .cast_mut()
+ .cast::<Self::Payload>(),
))
}
}
}
- #[inline]
- pub fn payload_offset(self) -> *const u8 {
- unsafe { self.get_ptr().byte_add(size_of::<ArenaHeader>()).cast() }
- }
-
/// # Safety
/// - this UntypedArenaPtr actual pointee type is T
/// - the pointer must be non-null