1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
#![no_std] extern crate alloc; use alloc::vec::Vec; extern crate cstring; pub use cstring::{cstr, CString}; mod v1 { use super::*; extern "C" { pub fn register_scope(scope: CString); pub fn device_error(err: CString); } } pub fn register_scope(scope: &str) { unsafe { v1::register_scope(cstr(scope)); } } pub fn device_error(scope: &str) { unsafe { v1::device_error(cstr(scope)); } } #[no_mangle] fn malloc(size: usize) -> *mut u8 { let mut buf = Vec::with_capacity(size as usize); let ptr = buf.as_mut_ptr(); core::mem::forget(buf); ptr }