Mercurial > crates > nonstick
comparison 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 |
comparison
equal
deleted
inserted
replaced
158:d5b7b28d754e | 159:634cd5f2ac8b |
---|---|
200 /// | 200 /// |
201 /// # Safety | 201 /// # Safety |
202 /// | 202 /// |
203 /// You have to provide a pointer to the start of an allocation that is | 203 /// You have to provide a pointer to the start of an allocation that is |
204 /// a valid 0-terminated C string. | 204 /// a valid 0-terminated C string. |
205 unsafe fn from_ptr(ptr: *mut c_char) -> Option<Self> { | 205 pub unsafe fn from_ptr(ptr: *mut c_char) -> Option<Self> { |
206 NonNull::new(ptr).map(|p| unsafe { Self(CHeapBox::from_ptr(p)) }) | 206 NonNull::new(ptr).map(|p| unsafe { Self(CHeapBox::from_ptr(p)) }) |
207 } | 207 } |
208 | 208 |
209 unsafe fn from_box<T>(bx: CHeapBox<T>) -> Self { | 209 /// Takes ownership of a CHeapBox. |
210 /// | |
211 /// # Safety | |
212 /// | |
213 /// The box has to point to a valid 0-terminated C string. | |
214 pub unsafe fn from_box<T>(bx: CHeapBox<T>) -> Self { | |
210 Self(CHeapBox::cast(bx)) | 215 Self(CHeapBox::cast(bx)) |
211 } | 216 } |
212 | 217 |
213 /// Zeroes the contents of a C string. | 218 /// Zeroes the contents of a C string. |
214 /// | 219 /// |