Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/memory/malloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ struct AllocHeader

pub fn kmalloc(size: usize) -> *mut c_void
{
if size == 0
{
crate::oops!("cannot allocate memory of size 0");
return core::ptr::null_mut::<c_void>();
}

let size = ferramenta::align(size, 0x10);
let pt_manager: &mut pagetable::Manager = unsafe
{
Expand Down Expand Up @@ -63,6 +69,12 @@ pub fn ksize(address: *mut c_void) -> usize

pub fn vmalloc(size: usize) -> *mut c_void
{
if size == 0
{
crate::oops!("cannot allocate memory of size 0");
return core::ptr::null_mut::<c_void>();
}

let size = ferramenta::align(size, 0x10);
let pt_manager: &mut pagetable::Manager = unsafe
{
Expand Down
5 changes: 4 additions & 1 deletion src/tty/basic_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,10 @@ fn allocate(size: usize, kernel_space: bool)
{
memory::vmalloc(size)
};

if address.is_null()
{
return;
}
let size = if kernel_space
{
memory::ksize(address)
Expand Down