Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/send-and-sync.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ to the heap.
use std::{
mem::{align_of, size_of},
ptr,
cmp::max,
};

struct Carton<T>(ptr::NonNull<T>);
Expand All @@ -105,8 +106,8 @@ impl<T> Carton<T> {
let mut memptr: *mut T = ptr::null_mut();
unsafe {
let ret = libc::posix_memalign(
(&mut memptr).cast(),
align_of::<T>(),
(&mut memptr as *mut *mut T).cast(),
max(align_of::<T>(), size_of::<usize>()),
size_of::<T>()
);
assert_eq!(ret, 0, "Failed to allocate or invalid alignment");
Expand Down