-
-
Save retep998/b97479b6c16edd92f6f12dcaa1418d0f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int pants() { | |
char *foo = crud(); | |
printf("Crud: %s\n", foo); | |
rust_free(foo); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[no_mangle] | |
pub extern fn crud() -> *const i8 { | |
CString::new("Hello!").unwrap().into_raw() | |
} | |
#[no_mangle] | |
pub extern fn rust_free(mem: *mut i8) { | |
unsafe { CString::from_raw(mem); } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment