I'm on a situation that I need to pass a slice s: &[u8]
to C++ for it to be used for a while, and then it should pass back to Rust for deletion.
I plan to pass the slice as a *const u8
by calling s.as_ptr()
(anyone knows a better way?). However, the C++ function does not consume the buffer immediately. It stores it on a queue.
How should I pass this to C++ and how to delete it in Rust after usage?