Lines Matching full:layout

8 pub mod layout;  module
26 use core::{alloc::Layout, ptr::NonNull};
141 /// via [`Layout`].
165 /// the requested layout has a smaller alignment.
168 /// Allocate memory based on `layout`, `flags` and `nid`.
170 /// On success, returns a buffer represented as `NonNull<[u8]>` that satisfies the layout
171 /// constraints (i.e. minimum size and alignment as specified by `layout`).
178 /// - valid for reads and writes for `layout.size()` bytes, until it is passed to
180 /// - aligned to `layout.align()`,
184 fn alloc(layout: Layout, flags: Flags, nid: NumaNode) -> Result<NonNull<[u8]>, AllocError> { in alloc() argument
187 unsafe { Self::realloc(None, layout, Layout::new::<()>(), flags, nid) } in alloc()
190 /// Re-allocate an existing memory allocation to satisfy the requested `layout` and
203 /// to `realloc` guarantees that the new or grown buffer has at least `Layout::size` bytes, but
220 /// - `old_layout` must match the `Layout` the allocation has been created with.
227 /// and old size, i.e. `ret_ptr[0..min(layout.size(), old_layout.size())] ==
228 /// p[0..min(layout.size(), old_layout.size())]`.
232 layout: Layout, in realloc() argument
233 old_layout: Layout, in realloc() argument
245 /// - `layout` must match the `Layout` the allocation has been created with.
247 unsafe fn free(ptr: NonNull<u8>, layout: Layout) { in free() argument
249 // allocator. We are passing a `Layout` with the smallest possible alignment, so it is in free()
254 Layout::new::<()>(), in free()
255 layout, in free()
263 /// Returns a properly aligned dangling pointer from the given `layout`.
264 pub(crate) fn dangling_from_layout(layout: Layout) -> NonNull<u8> { in dangling_from_layout()
265 let ptr = layout.align() as *mut u8; in dangling_from_layout()
267 // SAFETY: `layout.align()` (and hence `ptr`) is guaranteed to be non-zero. in dangling_from_layout()