Skip to content

Instantly share code, notes, and snippets.

@retep998
Forked from sargun/foo.c
Created March 31, 2016 09:51
Show Gist options
  • Save retep998/b97479b6c16edd92f6f12dcaa1418d0f to your computer and use it in GitHub Desktop.
Save retep998/b97479b6c16edd92f6f12dcaa1418d0f to your computer and use it in GitHub Desktop.
int pants() {
char *foo = crud();
printf("Crud: %s\n", foo);
rust_free(foo);
}
#[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