fix(napi): windows-i686 release build problem

This commit is contained in:
LongYinan 2020-11-14 00:22:10 +08:00
parent add6e2b9dc
commit 1669b3a8f1
No known key found for this signature in database
GPG key ID: C3666B7FC82ADAD7
2 changed files with 6 additions and 4 deletions

View file

@ -344,13 +344,15 @@ impl Env {
pub fn create_function(&self, name: &str, callback: Callback) -> Result<JsFunction> {
let mut raw_result = ptr::null_mut();
let name = CString::new(name.to_owned())?;
let len = name.as_bytes().len();
check_status(unsafe {
sys::napi_create_function(
self.0,
name.as_ptr() as *const c_char,
name.len() as _,
name.into_raw(),
len,
Some(callback),
callback as *mut c_void,
ptr::null_mut(),
&mut raw_result,
)
})?;

View file

@ -257,7 +257,7 @@ macro_rules! impl_object_methods {
where
T: NapiValue,
{
let key = CString::new(name)?;
let key = CString::new(name.to_owned())?;
check_status(unsafe {
sys::napi_set_named_property(self.0.env, self.0.value, key.as_ptr(), value.raw())
})