pub unsafe fn take_owned_cstring<Free>(
ptr: *mut i8,
free_fn: Free,
) -> Option<String>Expand description
Take ownership of an already-obtained Swift/Objective-C C string pointer
and free the source via free_fn.
This matches the common take_string(ptr) -> Option<String> pattern that
every doom-fish crate has been duplicating locally. Use this from your
crate’s bridge helper so the body lives in one place.
Returns Some(String) for a non-null, non-empty pointer; None otherwise.
In both branches the pointer is freed (the null branch is a no-op).
§Safety
The caller must guarantee that ptr is either null or a valid,
null-terminated C string allocated by the Swift / Objective-C bridge in a
way that free_fn correctly releases. The pointer is consumed exactly once.