Skip to content

Commit ec10051

Browse files
committed
remove box_free and replace with drop impl
1 parent 8430ec5 commit ec10051

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

example/mini_core.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,8 @@ impl<T: ?Sized + Unsize<U>, U: ?Sized, A: Allocator> CoerceUnsized<Box<U, A>> fo
490490

491491
impl<T: ?Sized, A: Allocator> Drop for Box<T, A> {
492492
fn drop(&mut self) {
493-
// drop is currently performed by compiler.
493+
// inner value is dropped by compiler
494+
libc::free(self.pointer.0 as *mut u8);
494495
}
495496
}
496497

@@ -507,11 +508,6 @@ unsafe fn allocate(size: usize, _align: usize) -> *mut u8 {
507508
libc::malloc(size)
508509
}
509510

510-
#[lang = "box_free"]
511-
unsafe fn box_free<T: ?Sized>(ptr: Unique<T>, _alloc: ()) {
512-
libc::free(ptr.pointer.0 as *mut u8);
513-
}
514-
515511
#[lang = "drop"]
516512
pub trait Drop {
517513
fn drop(&mut self);

0 commit comments

Comments
 (0)