add comment and reduce code in pre-open loading section

This commit is contained in:
Mark McCaskey
2019-04-19 13:24:41 -07:00
parent 5e504b77cd
commit 52279afbe2
2 changed files with 5 additions and 29 deletions

View File

@ -36,6 +36,7 @@ impl<T: Copy + ValueType> WasmPtr<T, Item> {
return Err(__WASI_EFAULT);
}
unsafe {
// clears bits below aligment amount (assumes power of 2) to align pointer
let aligner = |ptr: usize, align: usize| ptr & !(align - 1);
let cell_ptr = aligner(
memory.view::<u8>().as_ptr().add(self.offset as usize) as usize,