Lines Matching full:layout
14 use crate::alloc::{Allocator, Global, Layout};
184 let layout = match Layout::array::<T>(capacity) { in allocate_in() localVariable
185 Ok(layout) => layout, in allocate_in()
188 match alloc_guard(layout.size()) { in allocate_in()
193 AllocInit::Uninitialized => alloc.allocate(layout), in allocate_in()
194 AllocInit::Zeroed => alloc.allocate_zeroed(layout), in allocate_in()
198 Err(_) => handle_alloc_error(layout), in allocate_in()
218 let layout = Layout::array::<T>(capacity).map_err(|_| CapacityOverflow)?; in try_allocate_in() localVariable
219 alloc_guard(layout.size())?; in try_allocate_in()
221 AllocInit::Uninitialized => alloc.allocate(layout), in try_allocate_in()
222 AllocInit::Zeroed => alloc.allocate_zeroed(layout), in try_allocate_in()
224 let ptr = result.map_err(|_| AllocError { layout, non_exhaustive: () })?; in try_allocate_in()
272 fn current_memory(&self) -> Option<(NonNull<u8>, Layout)> { in current_memory() argument
276 … // We could use Layout::array here which ensures the absence of isize and usize overflows in current_memory()
284 let layout = Layout::from_size_align_unchecked(size, align); in current_memory() localVariable
285 Some((self.ptr.cast().into(), layout)) in current_memory()
440 let new_layout = Layout::array::<T>(cap); in grow_amortized()
459 let new_layout = Layout::array::<T>(cap); in grow_exact()
471 let (ptr, layout) = if let Some(mem) = self.current_memory() { mem } else { return Ok(()) }; in shrink()
479 unsafe { self.alloc.deallocate(ptr, layout) }; in shrink()
484 // `Layout::array` cannot overflow here because it would have in shrink()
487 let new_layout = Layout::from_size_align_unchecked(new_size, layout.align()); in shrink()
489 .shrink(ptr, layout, new_layout) in shrink()
490 .map_err(|_| AllocError { layout: new_layout, non_exhaustive: () })? in shrink()
504 new_layout: Result<Layout, LayoutError>, in finish_grow() argument
505 current_memory: Option<(NonNull<u8>, Layout)>, in finish_grow() argument
527 memory.map_err(|_| AllocError { layout: new_layout, non_exhaustive: () }.into()) in finish_grow()
533 if let Some((ptr, layout)) = self.current_memory() { in drop()
534 unsafe { self.alloc.deallocate(ptr, layout) } in drop()
545 Err(AllocError { layout, .. }) => handle_alloc_error(layout), in handle_reserve()