]> git.lizzy.rs Git - rust.git/commitdiff
improve and deduplicate comments
authorRalf Jung <post@ralfj.de>
Tue, 2 Jul 2019 10:51:00 +0000 (12:51 +0200)
committerRalf Jung <post@ralfj.de>
Tue, 2 Jul 2019 10:51:00 +0000 (12:51 +0200)
src/libstd/sys/unix/alloc.rs

index c5b6a360dd3449bc936afc62b45ae0e3f929fdb1..4ac66230e6ed7fc515dd7ba4de76e51f36a6d148 100644 (file)
@@ -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 fn alloc(&self, layout: Layout) -> *mut u8 {
 
     #[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 {