Check for allocation failure in alloc_aligned
This commit is contained in:
parent
aba7d5148a
commit
97464fb262
|
@ -138,7 +138,11 @@ pub unsafe fn alloc_aligned_box_slice<T, const ALIGN: usize>(len: usize) -> Box<
|
|||
#[inline(always)]
|
||||
pub unsafe fn alloc_aligned(len: usize, align: usize) -> *mut u8 {
|
||||
let layout = std::alloc::Layout::from_size_align_unchecked(len, align);
|
||||
std::alloc::alloc(layout)
|
||||
let ptr = std::alloc::alloc(layout);
|
||||
if ptr.is_null() {
|
||||
std::alloc::handle_alloc_error(layout);
|
||||
}
|
||||
ptr
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
|
|
Loading…
Reference in New Issue