Lines Matching full:layout

9 pub mod layout;  module
31 use core::{alloc::Layout, ptr::NonNull};
121 /// via [`Layout`].
140 /// Allocate memory based on `layout` and `flags`.
142 /// On success, returns a buffer represented as `NonNull<[u8]>` that satisfies the layout
143 /// constraints (i.e. minimum size and alignment as specified by `layout`).
150 /// - valid for reads and writes for `layout.size()` bytes, until it is passed to
152 /// - aligned to `layout.align()`,
156 fn alloc(layout: Layout, flags: Flags) -> Result<NonNull<[u8]>, AllocError> { in alloc() argument
159 unsafe { Self::realloc(None, layout, Layout::new::<()>(), flags) } in alloc()
162 /// Re-allocate an existing memory allocation to satisfy the requested `layout`.
167 /// to `realloc` guarantees that the new or grown buffer has at least `Layout::size` bytes, but
184 /// - `old_layout` must match the `Layout` the allocation has been created with.
191 /// and old size, i.e. `ret_ptr[0..min(layout.size(), old_layout.size())] ==
192 /// p[0..min(layout.size(), old_layout.size())]`.
196 layout: Layout, in realloc() argument
197 old_layout: Layout, in realloc() argument
208 /// - `layout` must match the `Layout` the allocation has been created with.
210 unsafe fn free(ptr: NonNull<u8>, layout: Layout) { in free() argument
212 // allocator. We are passing a `Layout` with the smallest possible alignment, so it is in free()
214 let _ = unsafe { Self::realloc(Some(ptr), Layout::new::<()>(), layout, Flags(0)) }; in free()
218 /// Returns a properly aligned dangling pointer from the given `layout`.
219 pub(crate) fn dangling_from_layout(layout: Layout) -> NonNull<u8> { in dangling_from_layout()
220 let ptr = layout.align() as *mut u8; in dangling_from_layout()
222 // SAFETY: `layout.align()` (and hence `ptr`) is guaranteed to be non-zero. in dangling_from_layout()