Use Layout::new consistently in DroplessArena::alloc.

This commit is contained in:
Nicholas Nethercote 2023-09-20 07:45:46 +10:00
parent 51edc21990
commit 98d97b7323

View File

@ -501,12 +501,13 @@ pub fn alloc<T>(&self, object: T) -> &mut T {
assert!(!mem::needs_drop::<T>());
assert!(mem::size_of::<T>() != 0);
let mem = if let Some(a) = self.alloc_raw_without_grow(Layout::for_value::<T>(&object)) {
let layout = Layout::new::<T>();
let mem = if let Some(a) = self.alloc_raw_without_grow(layout) {
a
} else {
// No free space left. Allocate a new chunk to satisfy the request.
// On failure the grow will panic or abort.
self.grow_and_alloc_raw(Layout::new::<T>())
self.grow_and_alloc_raw(layout)
} as *mut T;
unsafe {