mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-23 13:41:32 +00:00
Minimize unsafe block to unsafe code
This commit is contained in:
@ -159,8 +159,7 @@ impl LocalBacking {
|
||||
LocalOrImport::Import(imported_memory_index) => {
|
||||
// Write the initialization data to the memory that
|
||||
// we think the imported memory is.
|
||||
unsafe {
|
||||
let local_memory = &*imports.vm_memories[imported_memory_index];
|
||||
let local_memory = unsafe { &*imports.vm_memories[imported_memory_index] };
|
||||
let data_top = init_base + init.data.len();
|
||||
if local_memory.bound < data_top || data_top < init_base {
|
||||
return Err(vec![LinkError::Generic {
|
||||
@ -170,7 +169,6 @@ impl LocalBacking {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize data
|
||||
for init in module.info.data_initializers.iter() {
|
||||
@ -199,18 +197,16 @@ impl LocalBacking {
|
||||
LocalOrImport::Import(imported_memory_index) => {
|
||||
// Write the initialization data to the memory that
|
||||
// we think the imported memory is.
|
||||
unsafe {
|
||||
let memory_slice = unsafe {
|
||||
let local_memory = &*imports.vm_memories[imported_memory_index];
|
||||
let memory_slice =
|
||||
slice::from_raw_parts_mut(local_memory.base, local_memory.bound);
|
||||
slice::from_raw_parts_mut(local_memory.base, local_memory.bound)
|
||||
};
|
||||
|
||||
let mem_init_view =
|
||||
&mut memory_slice[init_base..init_base + init.data.len()];
|
||||
let mem_init_view = &mut memory_slice[init_base..init_base + init.data.len()];
|
||||
mem_init_view.copy_from_slice(&init.data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(memories
|
||||
.iter_mut()
|
||||
|
Reference in New Issue
Block a user