diff --git a/src/send-and-sync.md b/src/send-and-sync.md index 34539da..808a5c3 100644 --- a/src/send-and-sync.md +++ b/src/send-and-sync.md @@ -94,6 +94,7 @@ to the heap. use std::{ mem::{align_of, size_of}, ptr, + cmp::max, }; struct Carton(ptr::NonNull); @@ -105,8 +106,8 @@ impl Carton { let mut memptr: *mut T = ptr::null_mut(); unsafe { let ret = libc::posix_memalign( - (&mut memptr).cast(), - align_of::(), + (&mut memptr as *mut *mut T).cast(), + max(align_of::(), size_of::()), size_of::() ); assert_eq!(ret, 0, "Failed to allocate or invalid alignment");