MCPcopy Create free account
hub / github.com/dylan-sutton-chavez/edge-python / alloc

Method alloc

std/math/src/lib.rs:37–47  ·  view source on GitHub ↗
(&self, layout: Layout)

Source from the content-addressed store, hash-verified

35
36 unsafe impl GlobalAlloc for FreeListAlloc {
37 unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
38 if !INIT.load(Ordering::Relaxed) {
39 unsafe { (*HEAP.0.get()).init(POOL.0.get() as *mut u8, POOL_SIZE); }
40 INIT.store(true, Ordering::Relaxed);
41 }
42 unsafe {
43 (*HEAP.0.get())
44 .allocate_first_fit(layout)
45 .map_or(core::ptr::null_mut(), |p| p.as_ptr())
46 }
47 }
48
49 unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) {
50 unsafe { (*HEAP.0.get()).deallocate(NonNull::new_unchecked(ptr), layout); }

Callers

nothing calls this directly

Calls 2

loadMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected