Properly handle visibility

This commit is contained in:
topjohnwu
2023-07-06 04:54:33 -07:00
parent af2207433d
commit e8e8afa6c2
5 changed files with 137 additions and 164 deletions
-12
View File
@@ -256,22 +256,10 @@ impl PartialEq<Utf8CStr> for str {
}
}
pub fn ptr_to_str<'a, T>(ptr: *const T) -> &'a str {
if ptr.is_null() {
"(null)"
} else {
unsafe { CStr::from_ptr(ptr.cast()) }.to_str().unwrap_or("")
}
}
pub fn errno() -> &'static mut i32 {
unsafe { &mut *libc::__errno() }
}
pub fn error_str() -> &'static str {
unsafe { ptr_to_str(libc::strerror(*errno())) }
}
// When len is 0, don't care whether buf is null or not
#[inline]
pub unsafe fn slice_from_ptr<'a, T>(buf: *const T, len: usize) -> &'a [T] {