mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-22 05:01:33 +00:00
Use memory min and max values from module to generate environment memory
This commit is contained in:
@ -6,7 +6,10 @@ use std::mem::size_of;
|
||||
use std::os::raw::c_char;
|
||||
use std::slice;
|
||||
use wasmer_runtime_core::{
|
||||
module::Module, structures::TypedIndex, types::ImportedTableIndex, vm::Ctx,
|
||||
module::Module,
|
||||
structures::TypedIndex,
|
||||
types::{ImportedMemoryIndex, ImportedTableIndex},
|
||||
vm::Ctx,
|
||||
};
|
||||
|
||||
/// We check if a provided module is an Emscripten generated one
|
||||
@ -24,6 +27,11 @@ pub fn get_emscripten_table_size(module: &Module) -> (u32, Option<u32>) {
|
||||
(table.min, table.max)
|
||||
}
|
||||
|
||||
pub fn get_emscripten_memory_size(module: &Module) -> (u32, Option<u32>) {
|
||||
let (_, memory) = &module.0.imported_memories[ImportedMemoryIndex::new(0)];
|
||||
(memory.min, memory.max)
|
||||
}
|
||||
|
||||
pub unsafe fn write_to_buf(string: *const c_char, buf: u32, max: u32, ctx: &mut Ctx) -> u32 {
|
||||
let buf_addr = emscripten_memory_pointer!(ctx.memory(0), buf) as *mut c_char;
|
||||
|
||||
|
Reference in New Issue
Block a user