diff options
| author | Ralf Jung <post@ralfj.de> | 2019-07-02 12:51:00 +0200 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2019-07-02 12:51:00 +0200 |
| commit | 576369bfce92f98f78bdac31067d8cb8fee7b0a2 (patch) | |
| tree | 876d44c40bc513a46713615d97e3770a9a464195 | |
| parent | 2bad604587c5ca9f9fca25a803d00daa60a8d796 (diff) | |
| download | rust-576369bfce92f98f78bdac31067d8cb8fee7b0a2.tar.gz rust-576369bfce92f98f78bdac31067d8cb8fee7b0a2.zip | |
improve and deduplicate comments
| -rw-r--r-- | src/libstd/sys/unix/alloc.rs | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/libstd/sys/unix/alloc.rs b/src/libstd/sys/unix/alloc.rs index c5b6a360dd3..4ac66230e6e 100644 --- a/src/libstd/sys/unix/alloc.rs +++ b/src/libstd/sys/unix/alloc.rs @@ -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 { @@ -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 { |
