Skip to content

Commit e8c3ba5

Browse files
committed
refactor: free call to own_back as free is deprecated
1 parent 2f6be41 commit e8c3ba5

File tree

1 file changed

+1
-11
lines changed

1 file changed

+1
-11
lines changed

src/lib.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,7 @@ pub fn raw<T>(data: T) -> *mut T {
4949
#[cfg(any(feature = "alloc", feature = "std"))]
5050
#[inline]
5151
pub unsafe fn free<T>(pointer: *mut T) {
52-
#[cfg(any(feature = "panic-if-null", debug_assertions))]
53-
panic_if_null(pointer);
54-
// TODO: decide if remove this try to avoid crash when free a null pointer
55-
#[cfg(not(any(feature = "panic-if-null", debug_assertions)))]
56-
if pointer.is_null() {
57-
log::warn!("Trying to free a NULL pointer was ignored");
58-
return;
59-
}
60-
// CAUTION: this is unsafe
61-
Box::from_raw(pointer);
62-
// We let drop the boxed data.
52+
own_back(pointer);
6353
}
6454

6555
/// Opposite of [`raw<T>()`], to use Rust's ownership as usually.

0 commit comments

Comments
 (0)