Skip to content

Commit 8e51a0a

Browse files
committed
Use c"lit" for CStrings without unwrap
1 parent 820353a commit 8e51a0a

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

crates/profile/src/memory_usage.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,13 @@ fn memusage_linux() -> MemoryUsage {
6262
// mallinfo2 is very recent, so its presence needs to be detected at runtime.
6363
// Both are abysmally slow.
6464

65-
use std::ffi::CStr;
6665
use std::sync::atomic::{AtomicUsize, Ordering};
6766

6867
static MALLINFO2: AtomicUsize = AtomicUsize::new(1);
6968

7069
let mut mallinfo2 = MALLINFO2.load(Ordering::Relaxed);
7170
if mallinfo2 == 1 {
72-
let cstr = CStr::from_bytes_with_nul(b"mallinfo2\0").unwrap();
73-
mallinfo2 = unsafe { libc::dlsym(libc::RTLD_DEFAULT, cstr.as_ptr()) } as usize;
71+
mallinfo2 = unsafe { libc::dlsym(libc::RTLD_DEFAULT, c"mallinfo2".as_ptr()) } as usize;
7472
// NB: races don't matter here, since they'll always store the same value
7573
MALLINFO2.store(mallinfo2, Ordering::Relaxed);
7674
}

0 commit comments

Comments
 (0)