Skip to content

Instantly share code, notes, and snippets.

@lberserq
Created May 1, 2017 23:18
Show Gist options
  • Save lberserq/70df16f9df0dc796d990f41a61ffa88b to your computer and use it in GitHub Desktop.
Save lberserq/70df16f9df0dc796d990f41a61ffa88b to your computer and use it in GitHub Desktop.
extern crate libc;
use libc::*;
#[no_mangle]
pub unsafe extern "C" fn example(src: *mut u8, len : size_t) -> c_int{
if (!src.is_null()) {
*src = 1u8;
}
let k = len - 1;
*src.offset(k as isize) = 1u8; // if we comment this line unresolved external will dissapear
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment