remove unsafe code
This commit is contained in:
parent
305a9c66a6
commit
1bf37eb890
1 changed files with 11 additions and 19 deletions
30
src/lib.rs
30
src/lib.rs
|
@ -70,7 +70,7 @@ pub struct Args {
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub struct ServiceResult<'a> {
|
pub struct ServiceResult<'a> {
|
||||||
pub success: bool,
|
pub success: bool,
|
||||||
buf: &'static mut [i32],
|
buf: &'a mut [i32],
|
||||||
pub rets: &'a [i32],
|
pub rets: &'a [i32],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,15 +145,10 @@ macro_rules! call_method {
|
||||||
/// a macro for creating a ServiceResult struct, used with the `call!` macro
|
/// a macro for creating a ServiceResult struct, used with the `call!` macro
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! service_result {
|
macro_rules! service_result {
|
||||||
($nargs:expr, $nrets:expr) => { unsafe {
|
($nargs:expr, $nrets:expr) => { $crate::ServiceResult {
|
||||||
static mut BUF: [i32; $nargs + $nrets] = [0; $nargs + $nrets];
|
success: false,
|
||||||
let rets: &[i32] = &[];
|
buf: &mut [0; $nargs + $nrets],
|
||||||
let results = $crate::ServiceResult {
|
rets: &[],
|
||||||
success: false,
|
|
||||||
buf: &mut BUF,
|
|
||||||
rets,
|
|
||||||
};
|
|
||||||
results
|
|
||||||
}};
|
}};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,16 +156,13 @@ macro_rules! service_result {
|
||||||
/// a macro for creating a ServiceResult struct, used with the `call_method!` macro
|
/// a macro for creating a ServiceResult struct, used with the `call_method!` macro
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! method_service_result {
|
macro_rules! method_service_result {
|
||||||
($nargs:expr, $nrets:expr) => { unsafe {
|
($nargs:expr, $nrets:expr) => {
|
||||||
static mut BUF: [i32; $nargs + $nrets + 1] = [0; $nargs + $nrets + 1];
|
$crate::ServiceResult {
|
||||||
let rets: &[i32] = &[];
|
|
||||||
let results = $crate::ServiceResult {
|
|
||||||
success: false,
|
success: false,
|
||||||
buf: &mut BUF,
|
buf: &mut [0; $nargs + $nrets + 1],
|
||||||
rets,
|
rets: &[],
|
||||||
};
|
}
|
||||||
results
|
};
|
||||||
}};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// # ofw_call
|
/// # ofw_call
|
||||||
|
|
Loading…
Add table
Reference in a new issue