-
Notifications
You must be signed in to change notification settings - Fork 3
Pointer and Reference
squid233 edited this page Jan 27, 2025
·
7 revisions
The pointer type of method parameters are all converted to MemorySegment
.
No-const
pointer types can be assigned from native functions.
// C: void load(int* results)
void load(MemorySegment results);
void load(SegmentAllocator allocator, int[] results) {
MemorySegment seg = MemoryUtil.allocArray(allocator, results);
load(seg);
MemoryUtil.copy(seg, results);
}
For const
array type, simply allocate an array.
// C: void set(int* const values);
void set(MemorySegment values);
void set(SegmentAllocator allocator, int[] values) {
set(MemoryUtil.allocArray(allocator, values));
}
Copyright (c) 2022-2025 Overrun Organization. In case of any problems with this wiki, please search or create an issue.