| 40 | /* Frees a `wasm_alloc` buffer. Host must pass the exact `size` it requested, a mismatched length rebuilds the wrong Box layout. Null or zero is a no-op. */ |
| 41 | #[unsafe(no_mangle)] |
| 42 | pub unsafe extern "C" fn wasm_free(ptr: *mut u8, size: u32) { |
| 43 | if ptr.is_null() || size == 0 { return; } |
| 44 | unsafe { |
| 45 | let slice = core::slice::from_raw_parts_mut(ptr, size as usize); |
| 46 | let _ = Box::from_raw(slice as *mut [u8]); |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | #[unsafe(no_mangle)] |
| 51 | pub unsafe extern "C" fn register_code_module(spec_ptr: *const u8, spec_len: u32, src_ptr: *const u8, src_len: u32) { |