summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/sys/socket/mod.rs10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/sys/socket/mod.rs b/src/sys/socket/mod.rs
index a126f8b4..88fe02fe 100644
--- a/src/sys/socket/mod.rs
+++ b/src/sys/socket/mod.rs
@@ -258,14 +258,12 @@ pub fn sendmsg<'a>(fd: RawFd, iov: &[IoVec<&'a [u8]>], cmsgs: &[ControlMessage<'
len += cmsg.len();
capacity += cmsg.space();
}
- // Alignment hackery. Note that capacity is guaranteed to be a
- // multiple of size_t. Note also that the resulting vector claims
- // to have length == capacity, so it's presently uninitialized.
+ // Note that the resulting vector claims to have length == capacity,
+ // so it's presently uninitialized.
let mut cmsg_buffer = unsafe {
let mut vec = Vec::<u8>::with_capacity(len);
- let ptr = vec.as_mut_ptr();
- mem::forget(vec);
- Vec::<u8>::from_raw_parts(ptr as *mut _, len, len)
+ vec.set_len(len);
+ vec
};
{
let mut ptr = &mut cmsg_buffer[..];