Mercurial > crates > nonstick
diff src/libpam/memory.rs @ 159:634cd5f2ac8b
Separate logging into its own trait apart from the rest of PAM.
author | Paul Fisher <paul@pfish.zone> |
---|---|
date | Sat, 12 Jul 2025 18:16:18 -0400 |
parents | 4b3a5095f68c |
children | a1bb1d013567 |
line wrap: on
line diff
--- a/src/libpam/memory.rs Sat Jul 12 17:17:37 2025 -0400 +++ b/src/libpam/memory.rs Sat Jul 12 18:16:18 2025 -0400 @@ -202,11 +202,16 @@ /// /// You have to provide a pointer to the start of an allocation that is /// a valid 0-terminated C string. - unsafe fn from_ptr(ptr: *mut c_char) -> Option<Self> { + pub unsafe fn from_ptr(ptr: *mut c_char) -> Option<Self> { NonNull::new(ptr).map(|p| unsafe { Self(CHeapBox::from_ptr(p)) }) } - unsafe fn from_box<T>(bx: CHeapBox<T>) -> Self { + /// Takes ownership of a CHeapBox. + /// + /// # Safety + /// + /// The box has to point to a valid 0-terminated C string. + pub unsafe fn from_box<T>(bx: CHeapBox<T>) -> Self { Self(CHeapBox::cast(bx)) }