(length: usize)
| 52 | |
| 53 | #[unsafe(no_mangle)] |
| 54 | pub extern "C" fn alloc(length: usize) -> *mut u8 { |
| 55 | if length == 0 { |
| 56 | return core::ptr::null_mut(); |
| 57 | } |
| 58 | |
| 59 | unsafe { std::alloc::alloc(MemoryLayout::from_size_align_unchecked(length, 1)) } |
| 60 | } |
| 61 | |
| 62 | /// # Safety |
| 63 | /// `ptr`/`len` must come from a prior `alloc` call. |