Lines Matching refs:size
57 let (start, size) = unsafe { (HEAP.as_mut_ptr() as usize, HEAP.len()) }; in init()
61 unsafe { heap.init(start, size) }; in init()
65 pub fn aligned_boxed_slice(size: usize, align: usize) -> Option<Box<[u8]>> { in aligned_boxed_slice()
66 let size = NonZeroUsize::new(size)?.get(); in aligned_boxed_slice() localVariable
67 let layout = Layout::from_size_align(size, align).ok()?; in aligned_boxed_slice()
71 let slice_ptr = ptr::slice_from_raw_parts_mut(ptr, size); in aligned_boxed_slice()
78 unsafe extern "C" fn malloc(size: usize) -> *mut c_void { in malloc()
79 allocate(size, false).map_or(ptr::null_mut(), |p| p.cast::<c_void>().as_ptr()) in malloc()
83 unsafe extern "C" fn calloc(nmemb: usize, size: usize) -> *mut c_void { in calloc()
84 let Some(size) = nmemb.checked_mul(size) else { return ptr::null_mut() }; in calloc()
85 allocate(size, true).map_or(ptr::null_mut(), |p| p.cast::<c_void>().as_ptr()) in calloc()
118 let (ptr, size) = unsafe { in free()
122 let size = NonZeroUsize::new(size).unwrap(); in free() localVariable
123 let layout = malloc_layout(size).unwrap(); in free()
132 fn allocate(size: usize, zeroed: bool) -> Option<NonNull<usize>> { in allocate()
133 let size = NonZeroUsize::new(size)?.checked_add(mem::size_of::<usize>())?; in allocate() localVariable
134 let layout = malloc_layout(size)?; in allocate()
148 *ptr = size.get(); in allocate()
153 fn malloc_layout(size: NonZeroUsize) -> Option<Layout> { in malloc_layout()
156 Layout::from_size_align(size.get(), ALIGN).ok() in malloc_layout()