diff --git a/proxmox-io/src/read.rs b/proxmox-io/src/read.rs index d24a32fd..062615b3 100644 --- a/proxmox-io/src/read.rs +++ b/proxmox-io/src/read.rs @@ -296,7 +296,7 @@ impl ReadExt for R { fn read_exact_or_eof(&mut self, mut buf: &mut [u8]) -> io::Result { let mut read_bytes = 0; loop { - match self.read(&mut buf) { + match self.read(buf) { Ok(0) => { if read_bytes == 0 { return Ok(false); diff --git a/proxmox-io/src/vec/mod.rs b/proxmox-io/src/vec/mod.rs index 730dbb3b..98dce291 100644 --- a/proxmox-io/src/vec/mod.rs +++ b/proxmox-io/src/vec/mod.rs @@ -52,9 +52,8 @@ pub use byte_vec::ByteVecExt; /// marked as unsafe for good measure. #[inline] pub unsafe fn uninitialized(len: usize) -> Vec { - let mut out = Vec::with_capacity(len); - out.set_len(len); - out + let data = std::alloc::alloc(std::alloc::Layout::array::(len).unwrap()); + Vec::from_raw_parts(data as *mut u8, len, len) } /// Shortcut to zero out a slice of bytes.