mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-24 14:11:32 +00:00
Add fn for splitting borrow of memory & data in Ctx, use in WASI
This commit is contained in:
@ -401,6 +401,21 @@ impl Ctx {
|
||||
}
|
||||
}
|
||||
|
||||
/// Splits the borrow, getting both Memory and a mutable reference to
|
||||
/// the data type provided.
|
||||
///
|
||||
/// This method is required to access both at the same time.
|
||||
/// This is useful if the data stores information about locations in Wasm
|
||||
/// memory that a hostcall needs to access.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// This function must be called with the same type, `T`, that the `data`
|
||||
/// was set to.
|
||||
pub unsafe fn memory_and_data_mut<T>(&mut self, mem_index: u32) -> (&Memory, &mut T) {
|
||||
(self.memory(mem_index), &mut *(self.data as *mut T))
|
||||
}
|
||||
|
||||
/// Gives access to the emscripten symbol map, used for debugging
|
||||
pub unsafe fn borrow_symbol_map(&self) -> &Option<HashMap<u32, String>> {
|
||||
&(*self.module).info.em_symbol_map
|
||||
|
Reference in New Issue
Block a user