Matlab, Rust.
Box::from_raw(pointer); let c_string = CString::from_raw(*boxed_pointer); drop(c_string); drop(boxed_pointer); } } We first reconstruct the Box, and then reconstruct the CString. As long as the content of the string has not been modified, this will safely deallocate the string and avoid any memory