Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved FLSliceResult management #106

Merged
merged 4 commits into from
Aug 3, 2022
Merged

Improved FLSliceResult management #106

merged 4 commits into from
Aug 3, 2022

Conversation

bmeike
Copy link
Contributor

@bmeike bmeike commented Aug 2, 2022

Refactor FLSliceResult to avoid the crazy mallocing

@bmeike
Copy link
Contributor Author

bmeike commented Aug 2, 2022

This change affects a whole bunch of files. I don't think it is anything like necessary to read them all. Probably the C-language stuff is most important. ... and not the long_name_header_files, either.

Basically, what I've done is have the C code copy the native pointer and the length, that a FLSliceResult uses to frame a block of memory, directly into a Java object. It used to copy the FLSliceResult into the heap and give Java the pointer to the heap object.

Java never owns the block of memory that the FLSliceResult frames. It also doesn't malloc anything anymore. That means that it never has to free anything native, for a FLSliceResult.

Calls that used to take the pointer to the FLSliceResult (which had been on the heap) now take, instead, the pointer and length that used to be in the native FLSliceResult. Java just gets those things from its own FLSliceResult object.

@bmeike bmeike changed the title Fix/cbl 3211 Improved FLSliceResult management Aug 2, 2022
Copy link
Member

@borrrden borrrden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that now you've decomposed slices into their respective parts when crossing the JNI boundary, in order to avoid the weird malloc, and introduced a Java class to hold them on the managed side. Seems fine!

@bmeike bmeike merged commit 9a6a386 into master Aug 3, 2022
@bmeike bmeike deleted the fix/CBL-3211 branch August 3, 2022 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants