Skip to content

Commit

Permalink
improve and deduplicate comments
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Jul 2, 2019
1 parent 2bad604 commit 576369b
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/libstd/sys/unix/alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ unsafe impl GlobalAlloc for System {
unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
// jemalloc provides alignment less than MIN_ALIGN for small allocations.
// So only rely on MIN_ALIGN if size >= align.
// Also see <https://github.com/rust-lang/rust/issues/45955>.
// Also see <https://github.com/rust-lang/rust/issues/45955> and
// <https://github.com/rust-lang/rust/issues/62251#issuecomment-507580914>.
if layout.align() <= MIN_ALIGN && layout.align() <= layout.size() {
libc::malloc(layout.size()) as *mut u8
} else {
Expand All @@ -25,9 +26,7 @@ unsafe impl GlobalAlloc for System {

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

0 comments on commit 576369b

Please sign in to comment.