Use Box::from/into_raw()

This commit is contained in:
Sebastian Dröge 2016-05-13 17:43:32 +03:00
parent 6a3a42717f
commit 833148cef6

View file

@ -1,17 +1,12 @@
use std::mem;
#[no_mangle]
pub extern "C" fn filesrc_new() -> *mut FileSrc {
let mut instance = Box::new(FileSrc::new());
return &mut *instance;
let instance = Box::new(FileSrc::new());
return Box::into_raw(instance);
}
#[no_mangle]
pub extern "C" fn filesrc_drop(ptr: *mut FileSrc) {
let filesrc: &mut FileSrc = unsafe { &mut *ptr };
println!("drop");
drop(filesrc);
unsafe { Box::from_raw(ptr) };
}
#[no_mangle]