Lines Matching full:layout
6 use core::alloc::{GlobalAlloc, Layout};
17 pub(crate) unsafe fn krealloc_aligned(ptr: *mut u8, new_layout: Layout, flags: Flags) -> *mut u8 { in krealloc_aligned() argument
18 // Customized layouts from `Layout::from_size_align()` can have size < align, so pad first. in krealloc_aligned()
19 let layout = new_layout.pad_to_align(); in krealloc_aligned() localVariable
21 // Note that `layout.size()` (after padding) is guaranteed to be a multiple of `layout.align()` in krealloc_aligned()
24 let size = layout.size(); in krealloc_aligned()
29 // - `size` is greater than 0 since it's from `layout.size()` (which cannot be zero according in krealloc_aligned()
35 unsafe fn alloc(&self, layout: Layout) -> *mut u8 { in alloc()
36 // SAFETY: `ptr::null_mut()` is null and `layout` has a non-zero size by the function safety in alloc()
38 unsafe { krealloc_aligned(ptr::null_mut(), layout, GFP_KERNEL) } in alloc()
41 unsafe fn dealloc(&self, ptr: *mut u8, _layout: Layout) { in dealloc() argument
47 unsafe fn realloc(&self, ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8 { in realloc() argument
49 // - `new_size`, when rounded up to the nearest multiple of `layout.align()`, will not in realloc()
51 // - `layout.align()` is a proper alignment (i.e. not zero and must be a power of two). in realloc()
52 let layout = unsafe { Layout::from_size_align_unchecked(new_size, layout.align()) }; in realloc() localVariable
57 // - the size of `layout` is not zero because `new_size` is not zero by the function safety in realloc()
59 unsafe { krealloc_aligned(ptr, layout, GFP_KERNEL) } in realloc()
62 unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8 { in alloc_zeroed()
63 // SAFETY: `ptr::null_mut()` is null and `layout` has a non-zero size by the function safety in alloc_zeroed()
65 unsafe { krealloc_aligned(ptr::null_mut(), layout, GFP_KERNEL | __GFP_ZERO) } in alloc_zeroed()