Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
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> {
/// 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)
}
}