imprive at alloc failed

This commit is contained in:
pointer-to-bios 2024-09-23 12:55:00 +08:00
parent b2f52136df
commit 2c99270910
1 changed files with 4 additions and 2 deletions

View File

@ -1,10 +1,11 @@
use core::{
alloc::{GlobalAlloc, Layout},
ops::BitAnd,
ptr::{addr_of_mut, null_mut},
ptr::addr_of_mut,
};
use nonx_api::nonx_api;
#[repr(align(4096))]
struct PreInitializeAllocator {
base: [u128; 1024],
inited: bool,
@ -42,7 +43,8 @@ impl PreInitializeAllocator {
}
}
if start == 0 {
null_mut()
panic!("PreInitializeAllocator runs out. Bit map:\n{:#x}\n{:#x}\n{:#x}\n{:#x}\n{:#x}\n{:#x}\n{:#x}\n{:#x}",
self.base[0], self.base[1], self.base[2], self.base[3], self.base[4], self.base[5], self.base[6], self.base[7]);
} else {
addr_of_mut!(self.base[start]) as *mut u8
}