Avoid usage of the unstable Allocator trait
And also optimize init_sections to use the fact that allocate_frames returns zeroed frames.
This commit is contained in:
+1
-17
@@ -1,10 +1,3 @@
|
||||
use core::alloc::Allocator;
|
||||
|
||||
use alloc::boxed::Box;
|
||||
use alloc::vec::Vec;
|
||||
|
||||
use crate::memory::Enomem;
|
||||
|
||||
pub mod aligned_box;
|
||||
#[macro_use]
|
||||
pub mod int_like;
|
||||
@@ -34,13 +27,4 @@ macro_rules! dbg {
|
||||
};
|
||||
}
|
||||
|
||||
pub fn try_new_vec_with_exact_size<T, A: Allocator>(len: usize, alloc: A) -> Result<Vec<T, A>, Enomem> {
|
||||
let mut vec = Vec::<T, A>::new_in(alloc);
|
||||
vec.try_reserve_exact(len).map_err(|_| Enomem)?;
|
||||
Ok(vec.into())
|
||||
}
|
||||
pub fn try_box_slice_new<T, A: Allocator>(value: impl FnMut() -> T, len: usize, alloc: A) -> Result<Box<[T], A>, Enomem> {
|
||||
let mut vec = try_new_vec_with_exact_size(len, alloc)?;
|
||||
vec.resize_with(len, value);
|
||||
Ok(vec.into())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user