(bytes: ffi::xcw_native_shared_bytes)
| 525 | } |
| 526 | |
| 527 | unsafe fn copy_ffi_bytes(bytes: ffi::xcw_native_shared_bytes) -> Option<Bytes> { |
| 528 | if bytes.data.is_null() || bytes.length == 0 { |
| 529 | if !bytes.owner.is_null() { |
| 530 | unsafe { |
| 531 | ffi::xcw_native_release_shared_bytes(bytes); |
| 532 | } |
| 533 | } |
| 534 | return None; |
| 535 | } |
| 536 | |
| 537 | let copied = |
| 538 | unsafe { Bytes::copy_from_slice(std::slice::from_raw_parts(bytes.data, bytes.length)) }; |
| 539 | unsafe { |
| 540 | ffi::xcw_native_release_shared_bytes(bytes); |
| 541 | } |
| 542 | Some(copied) |
| 543 | } |
| 544 | |
| 545 | fn c_string(ptr: *const i8) -> Option<String> { |
| 546 | if ptr.is_null() { |
no test coverage detected