forked from AbleOS/ableos
ALLOCATOR: misc
This commit is contained in:
parent
bb3c1b6120
commit
8eebd50179
|
@ -150,7 +150,8 @@ impl Heap {
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
trace!("Allocating {:?}", ptr);
|
trace!("Allocating {:?}", ptr);
|
||||||
}
|
}
|
||||||
// FIXME: zero or scrub memory?
|
// FIXME: zero out memory to prevent leaking data
|
||||||
|
|
||||||
assert!(ptr.is_aligned_to(alignment));
|
assert!(ptr.is_aligned_to(alignment));
|
||||||
NonNull::new(ptr)
|
NonNull::new(ptr)
|
||||||
}
|
}
|
||||||
|
@ -166,7 +167,7 @@ impl Heap {
|
||||||
let size = unsafe { (*header).size_in_chunks };
|
let size = unsafe { (*header).size_in_chunks };
|
||||||
self.bitmap_set_range(start, size, false);
|
self.bitmap_set_range(start, size, false);
|
||||||
self.allocated_chunks -= size;
|
self.allocated_chunks -= size;
|
||||||
// FIXME: zero or scrub memory?
|
// FIXME: zero out memory to prevent leaking data
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Finds first hole that can fit an allocation of `size` chunks, returns the start of the
|
/// Finds first hole that can fit an allocation of `size` chunks, returns the start of the
|
||||||
|
@ -248,7 +249,10 @@ impl Heap {
|
||||||
return Some(start_of_free_chunks);
|
return Some(start_of_free_chunks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
trace!("No first fit found");
|
#[cfg(debug_assertions)]
|
||||||
|
{
|
||||||
|
trace!("No first fit found");
|
||||||
|
}
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -334,6 +338,8 @@ impl Heap {
|
||||||
unsafe impl Send for Heap {}
|
unsafe impl Send for Heap {}
|
||||||
|
|
||||||
#[alloc_error_handler]
|
#[alloc_error_handler]
|
||||||
fn alloc_error_handler(_layout: alloc::alloc::Layout) -> ! {
|
fn alloc_error_handler(layout: alloc::alloc::Layout) -> ! {
|
||||||
|
log::error!("allocation error: {:?}", layout);
|
||||||
|
// Todo: Maybe panic here instead
|
||||||
crate::arch::sloop()
|
crate::arch::sloop()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue