Skip to content

Commit 244f2a3

Browse files
committed
doc: Explicitly tell about safety of free<T>() with a ref doc safety section (and doc about ignoring null pointers)
1 parent 856fd72 commit 244f2a3

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/lib.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,15 @@ pub fn raw<T>(data: T) -> *mut T {
4545
}
4646

4747
#[deprecated(since = "0.7.2", note = "Use `own_back<T>()` instead")]
48-
#[allow(missing_docs)]
4948
#[cfg(any(feature = "alloc", feature = "std"))]
5049
#[inline]
50+
/// Call to `own_back<T>(pointer: *mut T)` ignoring the result.
51+
///
52+
/// This ignore null pointers without an error.
53+
///
54+
/// # Safety
55+
///
56+
/// Invalid pointer or call it twice could cause an undefined behavior or heap error and a crash.
5157
pub unsafe fn free<T>(pointer: *mut T) {
5258
let _ = own_back(pointer); // Ignore the must use lint as previous behavior was ignore null pointers
5359
}

0 commit comments

Comments
 (0)