Uses of Interface
jdk.incubator.foreign.SegmentAllocator
Package
Description
Classes to support low-level and efficient foreign memory/function access, directly from Java.
-
Uses of SegmentAllocator in jdk.incubator.foreign
Modifier and TypeMethodDescriptionstatic SegmentAllocator
SegmentAllocator.arenaAllocator
(long size, ResourceScope scope) Returns a native arena-based allocator which allocates a single memory segment, of given size (using malloc), and then responds to allocation request by returning different slices of that same segment (until no further allocation is possible).static SegmentAllocator
SegmentAllocator.arenaAllocator
(ResourceScope scope) Returns a native unbounded arena-based allocator.static SegmentAllocator
SegmentAllocator.ofScope
(ResourceScope scope) Returns a native allocator which responds to allocation requests by allocating new segments bound by the given resource scope, using theMemorySegment.allocateNative(long, long, ResourceScope)
factory.static SegmentAllocator
SegmentAllocator.ofSegment
(MemorySegment segment) Returns a segment allocator which responds to allocation requests by recycling a single segment; that is, each new allocation request will return a new slice starting at the segment offset0
(alignment constraints are ignored by this allocator).Modifier and TypeMethodDescriptionCLinker.downcallHandle
(Addressable symbol, SegmentAllocator allocator, MethodType type, FunctionDescriptor function) Obtain a foreign method handle, with the given type and featuring the given function descriptor, which can be used to call a target foreign function at the given address.static MemorySegment
CLinker.toCString
(String str, SegmentAllocator allocator) Converts a Java string into a UTF-8 encoded, null-terminated C string, storing the result into a native memory segment allocated using the provided allocator.CLinker.VaList.vargAsSegment
(MemoryLayout layout, SegmentAllocator allocator) Reads the next value as aMemorySegment
, and advances this va list's position.