Skip to content

Commit 576369b

Browse files
committed
improve and deduplicate comments
1 parent 2bad604 commit 576369b

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/libstd/sys/unix/alloc.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ unsafe impl GlobalAlloc for System {
99
unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
1010
// jemalloc provides alignment less than MIN_ALIGN for small allocations.
1111
// So only rely on MIN_ALIGN if size >= align.
12-
// Also see <https://github.com/rust-lang/rust/issues/45955>.
12+
// Also see <https://github.com/rust-lang/rust/issues/45955> and
13+
// <https://github.com/rust-lang/rust/issues/62251#issuecomment-507580914>.
1314
if layout.align() <= MIN_ALIGN && layout.align() <= layout.size() {
1415
libc::malloc(layout.size()) as *mut u8
1516
} else {
@@ -25,9 +26,7 @@ unsafe impl GlobalAlloc for System {
2526

2627
#[inline]
2728
unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8 {
28-
// jemalloc provides alignment less than MIN_ALIGN for small allocations.
29-
// So only rely on MIN_ALIGN if size >= align.
30-
// Also see <https://github.com/rust-lang/rust/issues/45955>.
29+
// See the comment above in `alloc` for why this check looks the way it does.
3130
if layout.align() <= MIN_ALIGN && layout.align() <= layout.size() {
3231
libc::calloc(layout.size(), 1) as *mut u8
3332
} else {

0 commit comments

Comments
 (0)