diff --git a/src/alloc.rs b/src/alloc.rs index 7a961ea6323..8bcac614d28 100644 --- a/src/alloc.rs +++ b/src/alloc.rs @@ -1,3 +1,7 @@ +// FORK NOTE: Copied from libsystem_alloc, removed unnecessary APIs, +// APIs take size/align directly instead of Layout + + // The minimum alignment guaranteed by the architecture. This value is used to diff --git a/src/lib.rs b/src/lib.rs index 4e1199d4558..e6b9a18cd87 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,16 +1,9 @@ - -#![feature(allocator_api)] -#![feature(alloc)] - -extern crate alloc; - pub use std::*; mod bench; mod table; mod shim; -#[path="alloc.rs"] -mod alloc2; +mod alloc; pub mod hash_map; pub mod hash_set; diff --git a/src/table.rs b/src/table.rs index f5a0cf9be7e..a6b8c0ebd3f 100644 --- a/src/table.rs +++ b/src/table.rs @@ -8,8 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use alloc::heap::{Heap, Alloc, Layout}; - +use alloc::{alloc, dealloc}; use cmp; use hash::{BuildHasher, Hash, Hasher}; use marker; @@ -756,8 +755,10 @@ impl RawTable { .expect("capacity overflow"), "capacity overflow"); - let buffer = Heap.alloc(Layout::from_size_align(size, alignment).unwrap()) - .unwrap_or_else(|e| Heap.oom(e)); + // FORK NOTE: Uses alloc shim instead of Heap.alloc + let buffer = alloc(size, alignment); + // FORK NOTE: Should handle null + debug_assert!(!buffer.is_null()); let hashes = buffer.offset(hash_offset as isize) as *mut HashUint; @@ -1162,7 +1163,7 @@ impl Drop for RawTable { let hashes_size = self.capacity() * size_of::(); let pairs_size = self.capacity() * size_of::<(K, V)>(); - let (align, _, size, oflo) = calculate_allocation(hashes_size, + let (align, _, _, oflo) = calculate_allocation(hashes_size, align_of::(), pairs_size, align_of::<(K, V)>()); @@ -1170,8 +1171,7 @@ impl Drop for RawTable { debug_assert!(!oflo, "should be impossible"); unsafe { - Heap.dealloc(self.hashes.ptr() as *mut u8, - Layout::from_size_align(size, align).unwrap()); + dealloc(self.hashes.ptr() as *mut u8, align); // Remember how everything was allocated out of one buffer // during initialization? We only need one call to free here. }