Skip to content

Commit 8293c2a

Browse files
committed
box_free_worker: Pull out version that just borrows alloc
1 parent b6aad76 commit 8293c2a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/liballoc/alloc.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,10 +229,15 @@ type BoxFreeAlloc<A> = A;
229229

230230
#[cfg_attr(not(test), lang = "box_free")]
231231
#[inline]
232-
pub(crate) unsafe fn box_free<T: ?Sized, A: Stage0Alloc>(ptr: Unique<T>, a: BoxFreeAlloc<A>) {
232+
pub(crate) unsafe fn box_free<T: ?Sized, A: Alloc>(ptr: Unique<T>, mut a: BoxFreeAlloc<A>) {
233+
box_free_worker(ptr, &mut a)
234+
}
235+
236+
#[inline]
237+
pub(crate) unsafe fn box_free_worker<T: ?Sized, A: Alloc>(ptr: Unique<T>, a: &mut BoxFreeAlloc<A>) {
233238
let size = size_of_val(&*ptr.as_ptr());
234239
let align = min_align_of_val(&*ptr.as_ptr());
235-
// We do not allocate for Box<T, A> when T is ZST, so deallocation is also not necessary.
240+
// We do not allocate for Box<T> when T is ZST, so deallocation is also not necessary.
236241
if size != 0 {
237242
let layout = Layout::from_size_align_unchecked(size, align);
238243
stage0_unphantom(a).dealloc(NonNull::from(ptr).cast(), layout);

0 commit comments

Comments
 (0)