Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Reduced need of unsafe in FFI #1100

Merged
merged 1 commit into from
Jun 26, 2022
Merged

Reduced need of unsafe in FFI #1100

merged 1 commit into from
Jun 26, 2022

Conversation

jorgecarleitao
Copy link
Owner

@jorgecarleitao jorgecarleitao commented Jun 24, 2022

This PR simplifies the API of FFI:

  • allocating the FFI structs on the heap is no longer required
  • exporting is now safe since we only need the struct to be on the stack
  • use Box on Bytes, further simplifying this core struct.
  • use write instead of write_unaligned
  • cleaup the integration test code

Backward incompatible changes

We no longer require a pointer to export - just export the struct to the stack and Box it if the other end of the interface requires a pointer. If the other end is the one allocating an empty struct, then write the exported struct to the pointer (which is unsafe as the receiving end must produce a valid pointer ^^).

@codecov
Copy link

codecov bot commented Jun 24, 2022

Codecov Report

Merging #1100 (69a9f9b) into main (88f05bb) will increase coverage by 0.01%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #1100      +/-   ##
==========================================
+ Coverage   81.24%   81.25%   +0.01%     
==========================================
  Files         366      366              
  Lines       35336    35337       +1     
==========================================
+ Hits        28707    28713       +6     
+ Misses       6629     6624       -5     
Impacted Files Coverage Δ
src/buffer/bytes.rs 98.11% <100.00%> (ø)
src/ffi/array.rs 89.67% <100.00%> (+0.47%) ⬆️
src/ffi/mod.rs 100.00% <100.00%> (ø)
src/ffi/stream.rs 67.80% <100.00%> (ø)
src/io/ipc/read/reader.rs 95.41% <0.00%> (-0.77%) ⬇️
src/array/utf8/mod.rs 82.74% <0.00%> (+0.95%) ⬆️
src/chunk.rs 90.47% <0.00%> (+7.14%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 88f05bb...69a9f9b. Read the comment docs.

@jorgecarleitao jorgecarleitao merged commit b679b06 into main Jun 26, 2022
@jorgecarleitao jorgecarleitao deleted the simpler_ffi branch June 26, 2022 13:14
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant