Layouts and Structs
Describe native memory layouts.
Describing Native Memory
Native data is rarely a single value. C uses structs, arrays, and unions. FFM models these shapes with memory layouts, letting you read and write structured native memory safely.
The Layout Family
The layout types form a small hierarchy:
ValueLayout: a primitive (int, long, double, address)SequenceLayout: a fixed-size array of a layoutStructLayout: fields laid out sequentiallyUnionLayout: overlapping fields
All lessons in this course
- Why FFM over JNI
- MemorySegment and Arena
- Downcall Handles
- Layouts and Structs