diff --git a/proxmox-io/src/vec/mod.rs b/proxmox-io/src/vec/mod.rs index 16d3a32e..b68fc750 100644 --- a/proxmox-io/src/vec/mod.rs +++ b/proxmox-io/src/vec/mod.rs @@ -21,7 +21,7 @@ //! //! # let size = 64usize; //! # let more = 64usize; -//! let mut buffer = vec::undefined(size); // A zero-initialized buffer with valgrind support +//! let mut buffer = vec::undefined(size); // A zero-initialized buffer //! //! let mut buffer = unsafe { vec::uninitialized(size) }; // an actually uninitialized buffer //! vec::clear(&mut buffer); // zero out an &mut [u8] @@ -78,54 +78,9 @@ pub fn zeroed(len: usize) -> Vec { /// Create a newly allocated byte vector of a specific size with "undefined" content. /// -/// The data will be zero initialized, but, if the `valgrind` feature is activated, it will be -/// marked as uninitialized for debugging. +/// The data will be zero initialized, but this function is meant to at some point gain support for +/// marking the data as uninitialized for tools such as `valgrind` at some point. #[inline] pub fn undefined(len: usize) -> Vec { - undefined_impl(len) -} - -#[cfg(not(feature = "valgrind"))] -fn undefined_impl(len: usize) -> Vec { zeroed(len) } - -#[cfg(feature = "valgrind")] -fn undefined_impl(len: usize) -> Vec { - let out = zeroed(len); - vg::make_slice_undefined(&out[..]); - out -} - -#[cfg(feature = "valgrind")] -mod vg { - type ValgrindValue = valgrind_request::Value; - - /// Mark a memory region as undefined when using valgrind, causing it to treat read access to - /// it as error. - #[inline] - pub(crate) fn make_mem_undefined(addr: *const u8, len: usize) -> ValgrindValue { - const MAKE_MEM_UNDEFINED: ValgrindValue = - (((b'M' as ValgrindValue) << 24) | ((b'C' as ValgrindValue) << 16)) + 1; - unsafe { - valgrind_request::do_client_request( - 0, - &[ - MAKE_MEM_UNDEFINED, - addr as usize as ValgrindValue, - len as ValgrindValue, - 0, - 0, - 0, - ], - ) - } - } - - /// Mark a slice of bytes as undefined when using valgrind, causing it to treat read access to - /// it as error. - #[inline] - pub(crate) fn make_slice_undefined(data: &[u8]) -> ValgrindValue { - make_mem_undefined(data.as_ptr(), data.len()) - } -}