MCPcopy Index your code
hub / github.com/1Password/zeroizing-alloc / clear_bytes

Function clear_bytes

src/lib.rs:41–47  ·  view source on GitHub ↗
(ptr: *mut u8, len: usize)

Source from the content-addressed store, hash-verified

39
40#[cfg(not(feature = "reference_impl"))]
41unsafe fn clear_bytes(ptr: *mut u8, len: usize) {
42 // We expect this to optimize into a `memset` for performance. Due to this function only being used via `read_volatile`,
43 // the compiler doesn't know that the slice this function will be wiping is about to be destroyed anyway.
44 //
45 // SAFETY: The caller must only pass a valid allocated object.
46 ptr.write_bytes(0x0, len);
47}
48
49// This is meant to avoid compiler optimizations while still retaining performance.
50//

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected