We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ef15976 commit f6a480aCopy full SHA for f6a480a
library/std/src/sys/pal/unix/alloc.rs
@@ -92,7 +92,10 @@ cfg_if::cfg_if! {
92
} else if #[cfg(target_os = "wasi")] {
93
#[inline]
94
unsafe fn aligned_malloc(layout: &Layout) -> *mut u8 {
95
- // C11 aligned_alloc requires that the size be a multiple of the alignment.
+ // C18 allows the implementation to return null if the alignment is "not supported", and
96
+ // some implementations, like wasi, choose to not support the case where the size is not
97
+ // a multiple of the alignment. This potentially wastes a bunch of space, but there's
98
+ // not a lot we can do about it.
99
// Layout already checks that the size rounded up doesn't overflow isize::MAX.
100
let align = layout.align();
101
let size = layout.size().next_multiple_of(align);
0 commit comments