Skip to content

Commit f6a480a

Browse files
committed
update comment about using aligned_alloc
1 parent ef15976 commit f6a480a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

library/std/src/sys/pal/unix/alloc.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,10 @@ cfg_if::cfg_if! {
9292
} else if #[cfg(target_os = "wasi")] {
9393
#[inline]
9494
unsafe fn aligned_malloc(layout: &Layout) -> *mut u8 {
95-
// C11 aligned_alloc requires that the size be a multiple of the alignment.
95+
// 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.
9699
// Layout already checks that the size rounded up doesn't overflow isize::MAX.
97100
let align = layout.align();
98101
let size = layout.size().next_multiple_of(align);

0 commit comments

Comments
 (0)