Skip to content

Commit

Permalink
Fixes double bug in Send-Sync example (#401)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mottl authored Feb 13, 2023
1 parent 2d3e6f6 commit 79b5366
Showing 1 changed file with 3 additions and 2 deletions.
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

0 comments on commit 79b5366

Please sign in to comment.