Skip to content

Commit

Permalink
std::alloc: checking if the alignment is, at least, a word size.
Browse files Browse the repository at this point in the history
so we do not error (at least on solarish systems) in that case.
close rust-langGH-124787
  • Loading branch information
devnexen committed May 6, 2024
1 parent 8cef37d commit 3fddb3b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion library/std/src/sys/pal/unix/alloc.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::alloc::{GlobalAlloc, Layout, System};
use crate::mem;
use crate::ptr;
use crate::sys::common::alloc::{realloc_fallback, MIN_ALIGN};

Expand Down Expand Up @@ -81,7 +82,7 @@ cfg_if::cfg_if! {
// [3]: https://bugs.chromium.org/p/chromium/issues/detail?id=138579
// [4]: https://chromium.googlesource.com/chromium/src/base/+/master/
// /memory/aligned_memory.cc
libc::memalign(layout.align(), layout.size()) as *mut u8
if layout.align() >= mem::size_of::<usize>() { libc::memalign(layout.align(), layout.size()) as *mut u8 } else { ptr::null_mut() }
}
} else if #[cfg(target_os = "wasi")] {
#[inline]
Expand Down

0 comments on commit 3fddb3b

Please sign in to comment.