Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions crates/oxc_allocator/src/from_raw_parts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
//! * [`Allocator::alloc_bytes_start`]
//! * [`Allocator::data_ptr`]
//! * [`Allocator::set_data_ptr`]
//! * [`Allocator::end_ptr`]

use std::{
alloc::Layout,
Expand Down Expand Up @@ -230,6 +231,15 @@ impl Allocator {
chunk_footer.ptr.get()
}

/// Get pointer to end of this [`Allocator`]'s current chunk (after the `ChunkFooter`).
pub fn end_ptr(&self) -> NonNull<u8> {
// SAFETY: `chunk_footer_ptr` returns pointer to a valid `ChunkFooter`,
// so stepping past it cannot be out of bounds of the chunk's allocation.
// If `Allocator` has not allocated, so `chunk_footer_ptr` returns a pointer to the static
// empty chunk, it's still valid.
unsafe { self.chunk_footer_ptr().add(1).cast::<u8>() }
}

/// Get reference to current [`ChunkFooter`].
///
/// # SAFETY
Expand Down
Loading