(dst: *mut u8, len: usize)
| 42 | /// typed access or drop. |
| 43 | #[inline] |
| 44 | pub(crate) unsafe fn zeroize_byte_ptr(dst: *mut u8, len: usize) { |
| 45 | if HAS_ASM { |
| 46 | // SAFETY: the caller supplies exclusive access to `len` writable bytes. |
| 47 | // `write_bytes` initializes every byte before constructing the slice. |
| 48 | unsafe { |
| 49 | core::ptr::write_bytes(dst, 0, len); |
| 50 | optimization_barrier(slice::from_raw_parts(dst, len)); |
| 51 | } |
| 52 | } else { |
| 53 | use core::mem::MaybeUninit; |
| 54 | |
| 55 | // SAFETY: the caller supplies exclusive access to this range. `MaybeUninit<u8>` permits |
| 56 | // uninitialized bytes and has byte alignment. |
| 57 | let bytes = unsafe { slice::from_raw_parts_mut(dst.cast::<MaybeUninit<u8>>(), len) }; |
| 58 | volatile_fill_slice(bytes, MaybeUninit::new(0)); |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | /// Fill a slice with a repeated value, preserving its type and alignment. |
| 63 | #[inline(always)] |
no test coverage detected