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

Method alloc

std/json/src/lib.rs:40–50  ·  view source on GitHub ↗
(&self, layout: Layout)

Source from the content-addressed store, hash-verified

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