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

Can I use ByteArray and NonDirect ByteBuffer with JNR #160

Open
furstenheim-goodnotes opened this issue Jan 15, 2025 · 0 comments
Open

Can I use ByteArray and NonDirect ByteBuffer with JNR #160

furstenheim-goodnotes opened this issue Jan 15, 2025 · 0 comments

Comments

@furstenheim-goodnotes
Copy link

Hi,
This might be a noob question. Can I use ByteArrays and ByteBuffers that are not allocateDirect with JNR?

Something like:

Java code

fun MyFunction(
            src: ByteArray,
            srcSize: Int
        ): Int

fun MyFunction(
            src: ByteBuffer,
            srcSize: Int
        ): Int

C code

int MyFunction(const char* src,
                              int srcSize);

As far as I am aware, if I do ByteBuffer.allocate(size) the underlying memory resides in the heap and can be moved around during GC compactation.

Could this lead to a segfault when using the memory in C? Does JNR protect against this?

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant