Skip to content

Instantly share code, notes, and snippets.

@sargun
Created March 31, 2016 09:43
Show Gist options
  • Save sargun/e665eb598aec0aaa5465fd330c6e2607 to your computer and use it in GitHub Desktop.
Save sargun/e665eb598aec0aaa5465fd330c6e2607 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 u8 {
Box::new("Hello!\0").as_ptr()
}
#[no_mangle]
pub extern fn rust_free(mem : *mut u8) {
unsafe {
drop(Box::from_raw(mem));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment