remove dependency on non-standard 'explicit_bzero()' on nightly builds

ffi
Avril 4 years ago
parent 1ecf0eab91
commit 1c61cee7ae
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -123,9 +123,19 @@ where W: Write
#[cfg(feature="explicit_clear")] #[cfg(feature="explicit_clear")]
{ {
use std::ffi::c_void; use std::ffi::c_void;
#[cfg(nightly)]
#[inline(never)] unsafe fn explicit_bzero(p: *mut c_void, s: usize)
{
std::ptr::write_bytes(p, 0, s);
asm!("");
}
#[cfg(not(nightly))]
extern "C" { extern "C" {
fn explicit_bzero(_: *mut c_void, _:usize); fn explicit_bzero(_: *mut c_void, _:usize);
} }
unsafe { unsafe {
explicit_bzero(self.buffer.as_mut_ptr() as *mut c_void, self.buffer.len()); explicit_bzero(self.buffer.as_mut_ptr() as *mut c_void, self.buffer.len());

Loading…
Cancel
Save