error_to_c

Function error_to_c 

Source
pub fn error_to_c(msg: impl AsRef<str>) -> *const c_char
Expand description

Convert an error message to a C string for returning across the C ABI.

ยงOwnership and lifetime

The returned pointer is borrowed and must not be freed by the caller. It remains valid until the next error_to_c() call on the same OS thread.

This design:

  • Prevents host-side leaks when the host copies the message into an owned string.
  • Avoids cross-dylib allocator issues (freeing memory in a different module).