]> git.proxmox.com Git - pve-lxc-syscalld.git/commitdiff
clippy fixups
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Fri, 7 Jan 2022 11:17:52 +0000 (12:17 +0100)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Fri, 7 Jan 2022 11:17:52 +0000 (12:17 +0100)
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
src/io/cmsg.rs
src/tools.rs

index 28acca64f17eb6a3512f64d1b9105c4add2aa542..293b69daeb6eca6843b742bc3c28b7ef6ee43da2 100644 (file)
@@ -14,11 +14,10 @@ pub const fn capacity<T: Sized>() -> usize {
 
 pub fn buffer<T: Sized>() -> Vec<u8> {
     let capacity = capacity::<T>();
-    let mut buf = Vec::with_capacity(capacity);
     unsafe {
-        buf.set_len(capacity);
+        let data = std::alloc::alloc(std::alloc::Layout::array::<u8>(capacity).unwrap());
+        Vec::from_raw_parts(data as *mut u8, capacity, capacity)
     }
-    buf
 }
 
 pub struct RawCmsgIterator<'a> {
index 01a32b59e8c7fcf9269565337493db710d513d0d..44cd943eb512e62cb3feead633c9097d8a8924b3 100644 (file)
@@ -54,9 +54,8 @@ pub mod vec {
     /// This is generally safe to call, but the contents of the vector are undefined.
     #[inline]
     pub unsafe fn uninitialized(len: usize) -> Vec<u8> {
-        let mut out = Vec::with_capacity(len);
-        out.set_len(len);
-        out
+        let data = std::alloc::alloc(std::alloc::Layout::array::<u8>(len).unwrap());
+        Vec::from_raw_parts(data as *mut u8, len, len)
     }
 }