Protect the hashmaps outside of rebuilds.

MozReview-Commit-ID: KACmfw4pZY2
This commit is contained in:
Bobby Holley 2017-09-27 17:01:34 -07:00
parent ef042899d2
commit 039fe176b9
3 changed files with 81 additions and 2 deletions

View file

@ -813,6 +813,24 @@ impl<K, V> RawTable<K, V> {
}
}
/// Access to the raw buffer backing this table.
pub fn raw_buffer(&self) -> (*const (), usize) {
debug_assert!(self.capacity() != 0);
let buffer = self.hashes.ptr() as *const ();
let size = {
let hashes_size = self.capacity() * size_of::<HashUint>();
let pairs_size = self.capacity() * size_of::<(K, V)>();
let (_, _, size, _) = calculate_allocation(hashes_size,
align_of::<HashUint>(),
pairs_size,
align_of::<(K, V)>());
round_up_to_page_size(size)
};
(buffer, size)
}
/// Creates a new raw table from a given capacity. All buckets are
/// initially empty.
pub fn new(capacity: usize) -> Result<RawTable<K, V>, FailedAllocationError> {