Skip to content

Commit

Permalink
comments
Browse files Browse the repository at this point in the history
  • Loading branch information
felipenoris committed Sep 25, 2018
1 parent 5ef7a3a commit 9f64fb8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,14 @@ by calling `rustdylib_free_rust_owned_string`, to let the memory be freed.
pub extern fn rustdylib_generate_rust_owned_string() -> *mut c_char {
let rust_string = String::from("The bomb: 💣");
let cstring = CString::new(rust_string).unwrap();
cstring.into_raw()
cstring.into_raw() // transfers ownership to the Julia process
}

#[no_mangle]
pub extern fn rustdylib_free_rust_owned_string(s: *mut c_char) {
unsafe {
if s.is_null() { return }
CString::from_raw(s)
CString::from_raw(s) // retakes ownership of the CString
};
}
```
Expand Down
4 changes: 2 additions & 2 deletions deps/RustDylib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ pub extern fn rustdylib_inspect_string(cstring: *const c_char) {
pub extern fn rustdylib_generate_rust_owned_string() -> *mut c_char {
let rust_string = String::from("The bomb: 💣");
let cstring = CString::new(rust_string).unwrap();
cstring.into_raw()
cstring.into_raw() // transfers ownership to the Julia process
}

#[no_mangle]
pub extern fn rustdylib_free_rust_owned_string(s: *mut c_char) {
unsafe {
if s.is_null() { return }
CString::from_raw(s)
CString::from_raw(s) // retakes ownership of the CString
};
}

0 comments on commit 9f64fb8

Please sign in to comment.