fix(napi): Windows i686 memory error

This commit is contained in:
LongYinan 2021-10-24 23:13:08 +08:00
parent d164a79514
commit 40c237ef19

View file

@ -141,7 +141,10 @@ pub fn js_function(attr: RawStream, input: RawStream) -> RawStream {
use std::ffi::CString;
use napi::{Env, Error, Status, NapiValue, NapiRaw, CallContext};
let mut argc = #arg_len_span as usize;
let mut raw_args: [napi::sys::napi_value; #arg_len_span] = [ptr::null_mut(); #arg_len_span];
#[cfg(all(target_os = "windows", target_arch = "x86"))]
let mut raw_args = vec![ptr::null_mut(); #arg_len_span];
#[cfg(not(all(target_os = "windows", target_arch = "x86")))]
let mut raw_args = [ptr::null_mut(); #arg_len_span];
let mut raw_this = ptr::null_mut();
unsafe {
@ -157,6 +160,9 @@ pub fn js_function(attr: RawStream, input: RawStream) -> RawStream {
}
let mut env = unsafe { Env::from_raw(raw_env) };
#[cfg(all(target_os = "windows", target_arch = "x86"))]
let ctx = CallContext::new(&mut env, cb_info, raw_this, raw_args.as_slice(), argc);
#[cfg(not(all(target_os = "windows", target_arch = "x86")))]
let ctx = CallContext::new(&mut env, cb_info, raw_this, &raw_args, argc);
#execute_js_function
}