about summary refs log tree commit diff
path: root/src/liballoc_jemalloc
diff options
context:
space:
mode:
authorSimon Sapin <simon.sapin@exyr.org>2018-04-03 15:41:09 +0200
committerSimon Sapin <simon.sapin@exyr.org>2018-04-12 22:53:03 +0200
commitba7081a033de4981ccad1e1525c8b5191ce02208 (patch)
treef1072f20039289e2f81131ea2d48440bbb2be63d /src/liballoc_jemalloc
parenta4caac5e93b801411fb59eeafa399240a7aa5fec (diff)
downloadrust-ba7081a033de4981ccad1e1525c8b5191ce02208.tar.gz
rust-ba7081a033de4981ccad1e1525c8b5191ce02208.zip
Make AllocErr a zero-size unit struct
Diffstat (limited to 'src/liballoc_jemalloc')
-rw-r--r--src/liballoc_jemalloc/lib.rs25
1 files changed, 3 insertions, 22 deletions
diff --git a/src/liballoc_jemalloc/lib.rs b/src/liballoc_jemalloc/lib.rs
index 616181d99bc..59a7e87e1ec 100644
--- a/src/liballoc_jemalloc/lib.rs
+++ b/src/liballoc_jemalloc/lib.rs
@@ -30,8 +30,6 @@ extern crate libc;
 pub use contents::*;
 #[cfg(not(dummy_jemalloc))]
 mod contents {
-    use core::ptr;
-
     use core::alloc::{Alloc, AllocErr, Layout};
     use alloc_system::System;
     use libc::{c_int, c_void, size_t};
@@ -106,14 +104,9 @@ mod contents {
     #[rustc_std_internal_symbol]
     pub unsafe extern fn __rde_alloc(size: usize,
                                      align: usize,
-                                     err: *mut u8) -> *mut u8 {
+                                     _err: *mut u8) -> *mut u8 {
         let flags = align_to_flags(align, size);
         let ptr = mallocx(size as size_t, flags) as *mut u8;
-        if ptr.is_null() {
-            let layout = Layout::from_size_align_unchecked(size, align);
-            ptr::write(err as *mut AllocErr,
-                       AllocErr::Exhausted { request: layout });
-        }
         ptr
     }
 
@@ -155,20 +148,13 @@ mod contents {
                                        old_align: usize,
                                        new_size: usize,
                                        new_align: usize,
-                                       err: *mut u8) -> *mut u8 {
+                                       _err: *mut u8) -> *mut u8 {
         if new_align != old_align {
-            ptr::write(err as *mut AllocErr,
-                       AllocErr::Unsupported { details: "can't change alignments" });
             return 0 as *mut u8
         }
 
         let flags = align_to_flags(new_align, new_size);
         let ptr = rallocx(ptr as *mut c_void, new_size, flags) as *mut u8;
-        if ptr.is_null() {
-            let layout = Layout::from_size_align_unchecked(new_size, new_align);
-            ptr::write(err as *mut AllocErr,
-                       AllocErr::Exhausted { request: layout });
-        }
         ptr
     }
 
@@ -176,18 +162,13 @@ mod contents {
     #[rustc_std_internal_symbol]
     pub unsafe extern fn __rde_alloc_zeroed(size: usize,
                                             align: usize,
-                                            err: *mut u8) -> *mut u8 {
+                                            _err: *mut u8) -> *mut u8 {
         let ptr = if align <= MIN_ALIGN && align <= size {
             calloc(size as size_t, 1) as *mut u8
         } else {
             let flags = align_to_flags(align, size) | MALLOCX_ZERO;
             mallocx(size as size_t, flags) as *mut u8
         };
-        if ptr.is_null() {
-            let layout = Layout::from_size_align_unchecked(size, align);
-            ptr::write(err as *mut AllocErr,
-                       AllocErr::Exhausted { request: layout });
-        }
         ptr
     }