File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed
Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change 44//! * [`Allocator::alloc_bytes_start`]
55//! * [`Allocator::data_ptr`]
66//! * [`Allocator::set_data_ptr`]
7+ //! * [`Allocator::end_ptr`]
78
89use std:: {
910 alloc:: Layout ,
@@ -230,6 +231,15 @@ impl Allocator {
230231 chunk_footer. ptr . get ( )
231232 }
232233
234+ /// Get pointer end of this [`Allocator`]'s current chunk (after the `ChunkFooter`).
235+ pub fn end_ptr ( & self ) -> NonNull < u8 > {
236+ // SAFETY: `chunk_footer_ptr` returns pointer to a valid `ChunkFooter`,
237+ // so stepping past it cannot be a out of bounds of the chunk's allocation.
238+ // If `Allocator` has not allocated, so `chunk_footer_ptr` returns a pointer to the static
239+ // empty chunk, it's still valid.
240+ unsafe { self . chunk_footer_ptr ( ) . add ( 1 ) . cast :: < u8 > ( ) }
241+ }
242+
233243 /// Get reference to current [`ChunkFooter`].
234244 ///
235245 /// # SAFETY
You can’t perform that action at this time.
0 commit comments