imaging a situation where we have
}// is vec still dropped by rust? or should i free it manually in c ? since there might be a chance for a language no longer take care of symbols went into unsafe region, what does rust do here?
Check the signature. That method just borrows and your
Vec still exists after it returns, so it will be dropped by Rust at the end of its scope.
More generally, if you allocated it in Rust, drop it in Rust (or not at all). There's no guarantee you and the C code are using the same allocator.
Edit: See also. And here's a possible way to have the same allocator on both sides of FFI, with some care (but I haven't vetted the crate myself).
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.