Skip to content

Commit

Permalink
Revert "removed an invalid safety comment"; was confused for a moment
Browse files Browse the repository at this point in the history
This reverts commit 8ab3c8b.
  • Loading branch information
nstilt1 committed Jan 22, 2024
1 parent 8ab3c8b commit 9961905
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions zeroize/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,10 @@ unsafe fn volatile_set<T: Copy + Sized>(dst: *mut T, src: T, count: usize) {
#[inline(always)]
pub unsafe fn zeroize_flat_type<T: Sized>(data: *mut T) {
let size = mem::size_of::<T>();
// Safety:
//
// This is safe because `mem::size_of<T>()` returns the exact size of the object in memory, and
// `data_ptr` points directly to the first byte of the data.
volatile_set(data as *mut u8, 0, size);
atomic_fence()
}
Expand Down

0 comments on commit 9961905

Please sign in to comment.