Skip to content

Commit

Permalink
fix Is the CString need to be freed? #10 (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
CGMossa authored Jun 1, 2024
1 parent c69d2ce commit 2472f65
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions src/myrustlib/src/hello.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
use std;
use std::ffi::CString;
use std::os::raw::c_char;

#[no_mangle]
pub extern fn string_from_rust() -> *const c_char {
let s = CString::new("Hello ピカチュウ !").unwrap();
let p = s.as_ptr();
std::mem::forget(s);
p
s.into_raw()
}

0 comments on commit 2472f65

Please sign in to comment.