Fix params of truncate

This commit is contained in:
Zhang Junyang
2023-07-21 13:27:51 +08:00
committed by Tate, Hongliang Tian
parent b5e04ea5ad
commit e3adb6e482
2 changed files with 4 additions and 4 deletions

View File

@ -80,7 +80,7 @@ impl MemoryRegion {
/// Remove range t from self, resulting in 0, 1 or 2 truncated ranges. /// Remove range t from self, resulting in 0, 1 or 2 truncated ranges.
/// We need to have this method since memory regions can overlap. /// We need to have this method since memory regions can overlap.
pub fn truncate(&self, t: MemoryRegion) -> Vec<MemoryRegion> { pub fn truncate(&self, t: &MemoryRegion) -> Vec<MemoryRegion> {
if self.base < t.base { if self.base < t.base {
if self.base + self.len > t.base { if self.base + self.len > t.base {
if self.base + self.len > t.base + t.len { if self.base + self.len > t.base + t.len {

View File

@ -172,7 +172,7 @@ pub fn init_memory_regions() {
for &r_unusable in &regions_unusable { for &r_unusable in &regions_unusable {
regions_dst.clear(); regions_dst.clear();
for r_usable in &*regions_src { for r_usable in &*regions_src {
regions_dst.append(&mut r_usable.truncate(r_unusable)); regions_dst.append(&mut r_usable.truncate(&r_unusable));
} }
swap(regions_src, regions_dst); swap(regions_src, regions_dst);
} }
@ -182,8 +182,8 @@ pub fn init_memory_regions() {
MEMORY_REGIONS.call_once(|| regions_unusable); MEMORY_REGIONS.call_once(|| regions_unusable);
} }
/// The entry point of kernel code, which should be defined by the package that // The entry point of kernel code, which should be defined by the package that
/// uses jinux-frame. // uses jinux-frame.
extern "Rust" { extern "Rust" {
fn jinux_main() -> !; fn jinux_main() -> !;
} }