Lines Matching full:layout

76 /// use std::alloc::{alloc, dealloc, handle_alloc_error, Layout};
79 /// let layout = Layout::new::<u16>();
80 /// let ptr = alloc(layout);
82 /// handle_alloc_error(layout);
88 /// dealloc(ptr, layout);
94 pub unsafe fn alloc(layout: Layout) -> *mut u8 { in alloc()
100 __rust_alloc(layout.size(), layout.align()) in alloc()
118 pub unsafe fn dealloc(ptr: *mut u8, layout: Layout) { in dealloc() argument
119 unsafe { __rust_dealloc(ptr, layout.size(), layout.align()) } in dealloc()
137 pub unsafe fn realloc(ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8 { in realloc() argument
138 unsafe { __rust_realloc(ptr, layout.size(), layout.align(), new_size) } in realloc()
157 /// use std::alloc::{alloc_zeroed, dealloc, Layout};
160 /// let layout = Layout::new::<u16>();
161 /// let ptr = alloc_zeroed(layout);
165 /// dealloc(ptr, layout);
171 pub unsafe fn alloc_zeroed(layout: Layout) -> *mut u8 { in alloc_zeroed()
172 unsafe { __rust_alloc_zeroed(layout.size(), layout.align()) } in alloc_zeroed()
178 fn alloc_impl(&self, layout: Layout, zeroed: bool) -> Result<NonNull<[u8]>, AllocError> { in alloc_impl() argument
179 match layout.size() { in alloc_impl()
180 0 => Ok(NonNull::slice_from_raw_parts(layout.dangling(), 0)), in alloc_impl()
181 // SAFETY: `layout` is non-zero in size, in alloc_impl()
183 let raw_ptr = if zeroed { alloc_zeroed(layout) } else { alloc(layout) }; in alloc_impl()
195 old_layout: Layout, in grow_impl() argument
196 new_layout: Layout, in grow_impl() argument
242 fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError> { in allocate()
243 self.alloc_impl(layout, false) in allocate()
247 fn allocate_zeroed(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError> { in allocate_zeroed()
248 self.alloc_impl(layout, true) in allocate_zeroed()
252 unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout) { in deallocate() argument
253 if layout.size() != 0 { in deallocate()
254 // SAFETY: `layout` is non-zero in size, in deallocate()
256 unsafe { dealloc(ptr.as_ptr(), layout) } in deallocate()
264 old_layout: Layout, in grow() argument
265 new_layout: Layout, in grow() argument
275 old_layout: Layout, in grow_zeroed() argument
276 new_layout: Layout, in grow_zeroed() argument
286 old_layout: Layout, in shrink() argument
287 new_layout: Layout, in shrink() argument
331 let layout = unsafe { Layout::from_size_align_unchecked(size, align) }; in exchange_malloc() localVariable
332 match Global.allocate(layout) { in exchange_malloc()
334 Err(_) => handle_alloc_error(layout), in exchange_malloc()
364 pub const fn handle_alloc_error(layout: Layout) -> ! { in handle_alloc_error() argument
365 const fn ct_error(_: Layout) -> ! { in handle_alloc_error() argument
369 fn rt_error(layout: Layout) -> ! { in handle_alloc_error() argument
371 __rust_alloc_error_handler(layout.size(), layout.align()); in handle_alloc_error()
375 unsafe { core::intrinsics::const_eval_select((layout,), ct_error, rt_error) } in handle_alloc_error()