Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std::boxed::Box;
- use libc::c_void;
- fn main() {
- show_ptr(get_ptr());
- }
- fn get_ptr() -> (*mut c_void, *mut c_void) {
- let x = vec!["Hello".to_string(), "World".to_string()].into_boxed_slice();
- let ptr = Box::into_raw(x);
- unsafe { std::mem::transmute::<_, (*mut c_void, *mut c_void)>(ptr) }
- }
- fn show_ptr(ptr: (*mut c_void, *mut c_void)) {
- let x = unsafe { Box::from_raw(std::mem::transmute::<_, *mut [String]>(ptr)) };
- println!("{:?}", x);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement