Skip to content

Commit e6414d2

Browse files
committed
box, RawVec: Generalize to not neccessary abort on OOM
1 parent 5701178 commit e6414d2

File tree

9 files changed

+235
-235
lines changed

9 files changed

+235
-235
lines changed

src/liballoc/abort_adapter.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ unsafe impl<A: Alloc> Alloc for AbortAdapter<A> {
5454
ptr: NonNull<u8>,
5555
layout: Layout,
5656
new_size: usize) -> Result<NonNull<u8>, Self::Err> {
57-
self.0.realloc(ptr, layout, new_size).or_else(|_| handle_alloc_error(layout))
57+
self.0.realloc(ptr, layout, new_size).or_else(|_| {
58+
let layout = Layout::from_size_align_unchecked(new_size, layout.align());
59+
handle_alloc_error(layout)
60+
})
5861
}
5962

6063
unsafe fn alloc_zeroed(&mut self, layout: Layout) -> Result<NonNull<u8>, Self::Err> {

0 commit comments

Comments
 (0)