Some functions return float pointing to an array of floats, or unsigned char pointing to a buffer of binary data. The nice thing to do would be to wrap this as a ByteBuffer... however the problem is the MemorySegment returned is 9223372036854775807 bytes long, because FFM doesn't know how much memory the C function actually allocated. And ByteBuffer has a max size of 2GB.
For some functions this can be manually worked around because they also return the size of the data. So then you can call MemorySegment.reinterpret(size).asByteBuffer(). But I don't know how to generate code for this automatically, so we'd be getting into hand made binding territory. And not all of them give you the size.
Some functions return float pointing to an array of floats, or unsigned char pointing to a buffer of binary data. The nice thing to do would be to wrap this as a ByteBuffer... however the problem is the MemorySegment returned is 9223372036854775807 bytes long, because FFM doesn't know how much memory the C function actually allocated. And ByteBuffer has a max size of 2GB.
For some functions this can be manually worked around because they also return the size of the data. So then you can call MemorySegment.reinterpret(size).asByteBuffer(). But I don't know how to generate code for this automatically, so we'd be getting into hand made binding territory. And not all of them give you the size.