fix memory area alignment #41

master
WangRunji 6 years ago
parent 520bb2d957
commit f29f5e4d35

@ -56,7 +56,9 @@ impl MemoryArea {
} }
/// Check the array is within the readable memory /// Check the array is within the readable memory
fn check_read_array<S>(&self, ptr: *const S, count: usize) -> bool { fn check_read_array<S>(&self, ptr: *const S, count: usize) -> bool {
ptr as usize >= self.start_addr && unsafe { ptr.add(count) as usize } <= self.end_addr // page align
ptr as usize >= Page::of_addr(self.start_addr).start_address()
&& unsafe { ptr.add(count) as usize } < Page::of_addr(self.end_addr + PAGE_SIZE - 1).start_address()
} }
/// Check the array is within the writable memory /// Check the array is within the writable memory
fn check_write_array<S>(&self, ptr: *mut S, count: usize) -> bool { fn check_write_array<S>(&self, ptr: *mut S, count: usize) -> bool {

Loading…
Cancel
Save