cstr_to_bytes

Function cstr_to_bytes 

Source
pub unsafe fn cstr_to_bytes<'a>(ptr: *const c_char) -> &'a [u8] 
Expand description

Convert a C string pointer into a borrowed byte slice.

§Safety

  • Assumes ptr is a valid, null-terminated UTF-8 C string pointer.
  • The returned slice borrows the underlying allocation; callers must ensure the C buffer outlives every use of the slice.

§Panics

Panics if ptr is null.