remove unsafe code

This commit is contained in:
husky 2023-07-20 15:16:41 -07:00
parent 305a9c66a6
commit 1bf37eb890
No known key found for this signature in database
GPG key ID: 6B3D8CB511646891

View file

@ -70,7 +70,7 @@ pub struct Args {
#[allow(dead_code)]
pub struct ServiceResult<'a> {
pub success: bool,
buf: &'static mut [i32],
buf: &'a mut [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
#[macro_export]
macro_rules! service_result {
($nargs:expr, $nrets:expr) => { unsafe {
static mut BUF: [i32; $nargs + $nrets] = [0; $nargs + $nrets];
let rets: &[i32] = &[];
let results = $crate::ServiceResult {
success: false,
buf: &mut BUF,
rets,
};
results
($nargs:expr, $nrets:expr) => { $crate::ServiceResult {
success: false,
buf: &mut [0; $nargs + $nrets],
rets: &[],
}};
}
@ -161,16 +156,13 @@ macro_rules! service_result {
/// a macro for creating a ServiceResult struct, used with the `call_method!` macro
#[macro_export]
macro_rules! method_service_result {
($nargs:expr, $nrets:expr) => { unsafe {
static mut BUF: [i32; $nargs + $nrets + 1] = [0; $nargs + $nrets + 1];
let rets: &[i32] = &[];
let results = $crate::ServiceResult {
($nargs:expr, $nrets:expr) => {
$crate::ServiceResult {
success: false,
buf: &mut BUF,
rets,
};
results
}};
buf: &mut [0; $nargs + $nrets + 1],
rets: &[],
}
};
}
/// # ofw_call