question about MemoryLayout
Hi! I'm learning a lot from your examples and articles.
After a long time reading up on Panama project I can't come up with a memory layout made up of a string (up to 100 characters) and an integer number. I need to define a sequence of records with two fields (name and age).
Your example from devox talk is a 4 character string (the tick of the share), so you can use an integer! but that's not my case!
thanks in advance
have a nice week
Do you mean 100 bytes when the string is decoded?
MemoryLayout.sequenceLayout(100, JAVA_BYTE).withName("name") might do the trick.
Thanks for your reply! I mean at most 100 bytes (could be less). The string represent a city name in my example. Not sure if its possible when the length is not a constant...
You could always encode the length separately if you want. Take a look at the method Arena.allocateFrom(String str)