Skip to content

Commit e7f48a6

Browse files
committed
box_free_worker: Pull out version that just borrows alloc
1 parent afa5677 commit e7f48a6

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/liballoc/alloc.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,14 @@ unsafe fn exchange_malloc(size: usize, align: usize) -> *mut u8 {
222222
#[cfg_attr(not(test), lang = "box_free")]
223223
#[inline]
224224
pub(crate) unsafe fn box_free<T: ?Sized, A: Alloc>(ptr: Unique<T>, mut a: A) {
225+
box_free_worker(ptr, &mut a)
226+
}
227+
228+
#[inline]
229+
pub(crate) unsafe fn box_free_worker<T: ?Sized, A: Alloc>(ptr: Unique<T>, a: &mut A) {
225230
let size = size_of_val(&*ptr.as_ptr());
226231
let align = min_align_of_val(&*ptr.as_ptr());
227-
// We do not allocate for Box<T, A> when T is ZST, so deallocation is also not necessary.
232+
// We do not allocate for Box<T> when T is ZST, so deallocation is also not necessary.
228233
if size != 0 {
229234
let layout = Layout::from_size_align_unchecked(size, align);
230235
a.dealloc(NonNull::from(ptr).cast(), layout);

0 commit comments

Comments
 (0)