Lines Matching +full:test +full:- +full:docs

1 // SPDX-License-Identifier: GPL-2.0
9 //! Reference: <https://docs.kernel.org/core-api/memory-allocation.html>
61 ) -> *mut crate::ffi::c_void,
81 /// - it accepts any pointer to a valid memory allocation allocated by this function.
82 /// - memory allocated by this function remains valid until it is passed to this function.
91 ) -> Result<NonNull<[u8]>, AllocError> { in call()
105 // - `self.0` is one of `krealloc`, `vrealloc`, `kvrealloc` and thus only requires that in call()
107 // - `ptr` is either NULL or valid by the safety requirements of this function. in call()
110 // - `self.0` is one of `krealloc`, `vrealloc`, `kvrealloc`. in call()
111 // - Those functions provide the guarantees of this function. in call()
130 pub fn aligned_layout(layout: Layout) -> Layout { in aligned_layout()
139 // - memory remains valid until it is explicitly freed,
140 // - passing a pointer to a valid memory allocation is OK,
141 // - `realloc` satisfies the guarantees, since `ReallocFunc::call` has the same.
152 ) -> Result<NonNull<[u8]>, AllocError> { in realloc()
173 /// // SAFETY: By the type invariant of `Box` the inner pointer of `vbox` is non-null.
189 /// - `ptr` must be a valid pointer to a [`Vmalloc`] allocation.
190 /// - `ptr` must remain valid for the entire duration of `'a`.
191 pub unsafe fn to_page<'a>(ptr: NonNull<u8>) -> page::BorrowedPage<'a> { in to_page()
200 // - `page` is a valid pointer to a `struct page`, given that by the safety requirements of in to_page()
202 // - By the safety requirements of this function `ptr` is valid for the entire lifetime of in to_page()
209 // - memory remains valid until it is explicitly freed,
210 // - passing a pointer to a valid memory allocation is OK,
211 // - `realloc` satisfies the guarantees, since `ReallocFunc::call` has the same.
222 ) -> Result<NonNull<[u8]>, AllocError> { in realloc()
230 // - memory remains valid until it is explicitly freed,
231 // - passing a pointer to a valid memory allocation is OK,
232 // - `realloc` satisfies the guarantees, since `ReallocFunc::call` has the same.
243 ) -> Result<NonNull<[u8]>, AllocError> { in realloc()
260 #[test]
261 fn test_alignment() -> Result { in test_alignment()
265 // These two structs are used to test allocating aligned memory. in test_alignment()
276 fn new() -> Result<Self> { in test_alignment()
280 fn is_aligned_to(&self, align: usize) -> bool { in test_alignment()
284 addr & (align - 1) == 0 in test_alignment()