Mapping List<String> to char **
Sebastian Stenzel
sebastian.stenzel at gmail.com
Fri Jun 11 14:32:30 UTC 2021
Hi,
imagine you want to invoke a native method with (among others) these params:
int argc, char **argv
On the Java side I have a `List<String>`.
Currently, ...
1. I create a new SequenceLayout of type MemoryLayouts.ADDRESS and of size `argc`
2. I allocate a new MemorySegment `argv` using aforementioned layout
3. For each of my elements, I call CLinker.toCString and fill in the address of the returned segment into `argv`
I feel like there should be an easier way to achieve this. Is there some utility to create a MemorySegment from an array of addresses? (I know I can create an array of longs, but I don't want to rely on a 64 bit architecture).
Thanks,
Sebastian
More information about the panama-dev
mailing list