From 833148cef6ee09d37283cdeb5fd89253caf799ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Fri, 13 May 2016 17:43:32 +0300 Subject: [PATCH] Use Box::from/into_raw() --- src/rsfilesrc.rs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/rsfilesrc.rs b/src/rsfilesrc.rs index 9543e6db..e4fae37b 100644 --- a/src/rsfilesrc.rs +++ b/src/rsfilesrc.rs @@ -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]