Skip to main content

cstr_to_string

Function cstr_to_string 

Source
pub unsafe fn cstr_to_string(ptr: *const c_char) -> Result<String>
Expand description

Converts a borrowed C string into an owned String.

Returns CpdbError::NullPointer when ptr is null. Invalid UTF-8 is replaced with U+FFFD (lossy) — cpdb-libs strings should always be valid UTF-8, but we do not trust that strictly.

§Safety

ptr must either be null or point at a NUL-terminated C string that stays valid for the duration of this call.