Should I pass a mutable reference or transfer ownership of a variable in the context of FFI?
- 阅读更多 关于 Should I pass a mutable reference or transfer ownership of a variable in the context of FFI?
问题 I have a program that utilizes a Windows API via a C FFI (via winapi-rs). One of the functions expects a pointer to a pointer to a string as an output parameter. The function will store its result into this string. I'm using a variable of type WideCString for this string. Can I "just" pass in a mutable ref to a ref to a string into this function (inside an unsafe block) or should I rather use a functionality like .into_raw() and .from_raw() that also moves the ownership of the variable to the