Skip to content

Commit c05546a

Browse files
authored
Merge pull request #71 from CalebLBaker/master
Access to non-available memory areas
2 parents 30d64f4 + 27dc1b6 commit c05546a

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/memory_map.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@ pub struct MemoryMapTag {
2222

2323
impl MemoryMapTag {
2424
/// Return an iterator over all AVAILABLE marked memory areas.
25-
pub fn memory_areas(&self) -> MemoryAreaIter {
25+
pub fn memory_areas(&self) -> impl Iterator<Item = &MemoryArea> {
26+
self.all_memory_areas().filter(|entry| entry.typ == 1)
27+
}
28+
29+
/// Return an iterator over all marked memory areas.
30+
pub fn all_memory_areas(&self) -> MemoryAreaIter {
2631
let self_ptr = self as *const MemoryMapTag;
2732
let start_area = (&self.first_area) as *const MemoryArea;
2833
MemoryAreaIter {
@@ -91,7 +96,7 @@ pub enum MemoryAreaType {
9196
Defective,
9297
}
9398

94-
/// An iterator over Available memory areas.
99+
/// An iterator over all memory areas
95100
#[derive(Clone, Debug)]
96101
pub struct MemoryAreaIter<'a> {
97102
current_area: u64,
@@ -108,9 +113,7 @@ impl<'a> Iterator for MemoryAreaIter<'a> {
108113
} else {
109114
let area = unsafe{&*(self.current_area as *const MemoryArea)};
110115
self.current_area = self.current_area + (self.entry_size as u64);
111-
if area.typ == 1 {
112-
Some(area)
113-
} else {self.next()}
116+
Some(area)
114117
}
115118
}
116119
}

0 commit comments

Comments
 (0)