mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2025-06-06 23:48:57 +00:00
Use Box::from/into_raw()
This commit is contained in:
parent
6a3a42717f
commit
833148cef6
1 changed files with 3 additions and 8 deletions
|
@ -1,17 +1,12 @@
|
||||||
use std::mem;
|
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn filesrc_new() -> *mut FileSrc {
|
pub extern "C" fn filesrc_new() -> *mut FileSrc {
|
||||||
let mut instance = Box::new(FileSrc::new());
|
let instance = Box::new(FileSrc::new());
|
||||||
return &mut *instance;
|
return Box::into_raw(instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn filesrc_drop(ptr: *mut FileSrc) {
|
pub extern "C" fn filesrc_drop(ptr: *mut FileSrc) {
|
||||||
let filesrc: &mut FileSrc = unsafe { &mut *ptr };
|
unsafe { Box::from_raw(ptr) };
|
||||||
|
|
||||||
println!("drop");
|
|
||||||
drop(filesrc);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
|
|
Loading…
Reference in a new issue