Alloc in the live VM; 0 when outside run() or OOM.
(obj: HeapObj)
| 243 | pub unsafe extern "C" fn host_edge_encode(tag: u32, ptr: *const u8, len: u32) -> u32 { |
| 244 | // Alloc in the live VM; 0 when outside run() or OOM. |
| 245 | fn alloc_and_put(obj: HeapObj) -> u32 { |
| 246 | match with_vm(|vm| vm.heap.alloc(obj).ok()).flatten() { |
| 247 | Some(val) => put_val(val), |
| 248 | None => 0, |
| 249 | } |
| 250 | } |
| 251 | let bytes = unsafe { safe_bytes(ptr, len) }; |
| 252 | match classify_encode(tag, bytes) { |
| 253 | EncodeRequest::Direct(bits) => put_val(Val(bits)), |
no test coverage detected