These two functions are pretty unsafe, but having these assertions makes
it easier to catch UB in testing.
// TODO use <*{const,mut} _>::addr instead of as when the strict_provenance feature is stable rust-lang/rust#95228
// we might need <*{const,mut} _>::expose_provenance for strict provenance, dependening on how we recreate a pointer later
let ptr : *const _ = $ptr;
+ debug_assert!(!$ptr.is_null());
HeapCellValue::from_ptr_addr(ptr as usize)
}};
}
impl UntypedArenaPtr {
#[inline(always)]
pub fn build_with(ptr: usize) -> Self {
+ debug_assert!(ptr != 0);
UntypedArenaPtr::new().with_ptr(ptr as u64)
}
}
#[inline]
pub fn get_tag(self) -> ArenaHeaderTag {
unsafe {
+ debug_assert!(!self.get_ptr().is_null());
let header = *(self.get_ptr() as *const ArenaHeader);
header.get_tag()
}