Function ffi_support::opt_rust_string_from_c [−][src]
pub unsafe fn opt_rust_string_from_c(c_string: *const c_char) -> Option<String>
👎 Deprecated since 0.3.0:
Please use FfiStr::into_opt_string instead
Same as rust_string_from_c
, but returns None if c_string
is null instead of asserting.
Safety
This is unsafe because we dereference 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.