3 ms·
Is it possible to lay out some struct-like thing into that memory segment and just read the whole thing for convenience? Appreciate the example. Thank you.
by renewiltord 4y ago
Is it possible to lay out some struct-like thing into that memory segment and just read the whole thing for convenience?
Appreciate the example. Thank you.
- kaba0 4y agoYes, for FFI jextract can also auto-generate helper classes, so some C struct named tb_cell with a field named ch typed int, you could access its fields like tb_cell.ch$get(memorySegment) and tb_cell.ch$set(memorySegment, value). Of course you are not required to do FFI, you may want to use this API to speed up some very memory-sensitive operation. Then you can define your own memory layout, specifying precisely endianness, alignment, padding, anything, and access it comfortably through these APIs.
- renewiltord 4y agoWell, wow, I'm going to take a look at this. Much appreciated. Do you happen to know if the `get` causes allocation in the Java side there?