[][src]Function ffi_support::opt_rust_str_from_c

pub unsafe fn opt_rust_str_from_c<'a>(
    c_string: *const c_char
) -> Option<&'a str>
Deprecated since 0.3.0:

Please use FfiStr::as_opt_str instead

Same as rust_string_from_c, but returns None if c_string is null instead of asserting.

Safety

This is unsafe because we read from a raw pointer, which may or may not be valid.

We also assume c_string is a null terminated string, and have no way of knowing if that's actually true. If it's not, we'll read arbitrary memory from the heap until we see a '\0', which can result in a enormous number of problems.