Skip to content

Commit 08c6162

Browse files
tedstaphil-opp
authored andcommitted
Make MemoryMapIter be Send (#29)
1 parent eda6fe7 commit 08c6162

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/memory_map.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ impl MemoryMapTag {
1313
let self_ptr = self as *const MemoryMapTag;
1414
let start_area = (&self.first_area) as *const MemoryArea;
1515
MemoryAreaIter {
16-
current_area: start_area,
17-
last_area: (self_ptr as u64 + (self.size - self.entry_size) as u64)
18-
as *const MemoryArea,
16+
current_area: start_area as u64,
17+
last_area: (self_ptr as u64 + (self.size - self.entry_size) as u64),
1918
entry_size: self.entry_size,
2019
}
2120
}
@@ -46,8 +45,8 @@ impl MemoryArea {
4645

4746
#[derive(Clone, Debug)]
4847
pub struct MemoryAreaIter {
49-
current_area: *const MemoryArea,
50-
last_area: *const MemoryArea,
48+
current_area: u64,
49+
last_area: u64,
5150
entry_size: u32,
5251
}
5352

@@ -57,9 +56,8 @@ impl Iterator for MemoryAreaIter {
5756
if self.current_area > self.last_area {
5857
None
5958
} else {
60-
let area = unsafe{&*self.current_area};
61-
self.current_area = ((self.current_area as u64) + self.entry_size as u64)
62-
as *const MemoryArea;
59+
let area = unsafe{&*(self.current_area as *const MemoryArea)};
60+
self.current_area = self.current_area + (self.entry_size as u64);
6361
if area.typ == 1 {
6462
Some(area)
6563
} else {self.next()}

0 commit comments

Comments
 (0)