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