mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 22:09:09 +00:00
wasm: address PR feedback
This commit is contained in:
parent
a7899bdded
commit
20e46fbda4
2 changed files with 7 additions and 8 deletions
|
@ -1,6 +1,8 @@
|
|||
use core::cell::Cell;
|
||||
use libc::c_char;
|
||||
use roc_gen_wasm::wasm_module::{Export, ExportType};
|
||||
use std::collections::hash_map::DefaultHasher;
|
||||
use std::ffi::CStr;
|
||||
use std::hash::{Hash, Hasher};
|
||||
use std::marker::PhantomData;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
@ -236,13 +238,10 @@ fn get_roc_panic_msg(instance: &wasmer::Instance, memory: &Memory) -> Option<Str
|
|||
return None;
|
||||
}
|
||||
let msg_index = msg_addr as usize;
|
||||
let msg_len = memory_bytes[msg_index..]
|
||||
.iter()
|
||||
.position(|c| *c == 0)
|
||||
.unwrap();
|
||||
let msg_bytes = memory_bytes[msg_index..][..msg_len].to_vec();
|
||||
let msg = unsafe { String::from_utf8_unchecked(msg_bytes) };
|
||||
Some(msg)
|
||||
let msg_ptr = memory_bytes[msg_index..].as_ptr();
|
||||
let msg_cstr = unsafe { CStr::from_ptr(msg_ptr as *const c_char) };
|
||||
let msg_str = msg_cstr.to_str().unwrap();
|
||||
Some(msg_str.to_string())
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue