electronstudio / jaylib-ffm

Other
7 stars 1 forks source link

functions that return return pointer types #8

Closed electronstudio closed 3 months ago

electronstudio commented 3 months ago

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.

electronstudio commented 3 months ago

For now I'm just going to resize every ByteBuffer to 2GB. User can then resize them again if they know the real size.