Fixes double bug in Send-Sync example (#401)

pull/404/head
Dmitry Mottl 2 years ago committed by GitHub
parent 2d3e6f67d5
commit 79b53665a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -94,6 +94,7 @@ to the heap.
use std::{ use std::{
mem::{align_of, size_of}, mem::{align_of, size_of},
ptr, ptr,
cmp::max,
}; };
struct Carton<T>(ptr::NonNull<T>); struct Carton<T>(ptr::NonNull<T>);
@ -105,8 +106,8 @@ impl<T> Carton<T> {
let mut memptr: *mut T = ptr::null_mut(); let mut memptr: *mut T = ptr::null_mut();
unsafe { unsafe {
let ret = libc::posix_memalign( let ret = libc::posix_memalign(
(&mut memptr).cast(), (&mut memptr as *mut *mut T).cast(),
align_of::<T>(), max(align_of::<T>(), size_of::<usize>()),
size_of::<T>() size_of::<T>()
); );
assert_eq!(ret, 0, "Failed to allocate or invalid alignment"); assert_eq!(ret, 0, "Failed to allocate or invalid alignment");

Loading…
Cancel
Save