diff options
Diffstat (limited to 'components/hashglobe/src/table.rs')
-rw-r--r-- | components/hashglobe/src/table.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/components/hashglobe/src/table.rs b/components/hashglobe/src/table.rs index 602cd2131b4..23b2ea00f16 100644 --- a/components/hashglobe/src/table.rs +++ b/components/hashglobe/src/table.rs @@ -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> { |