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::{
mem::{align_of, size_of},
ptr,
cmp::max,
};
struct Carton<T>(ptr::NonNull<T>);
@ -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");

Loading…
Cancel
Save