Uses of Interface jdk.incubator.foreign.SegmentAllocator (Java SE 17 & JDK 17)
Description: use: module: jdk.incubator.foreign, package: jdk.incubator.foreign, interface: SegmentAllocator

# Uses of Interface
jdk.incubator.foreign.SegmentAllocator

Packages that use SegmentAllocator
Package
Description
jdk.incubator.foreign
Classes to support low-level and efficient foreign memory/function access, directly from Java.

- ## Uses of SegmentAllocator in jdk.incubator.foreign

  Methods in jdk.incubator.foreign that return SegmentAllocator
  Modifier and Type
  Method
  Description
  `static 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 the `MemorySegment.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 offset `0` (alignment constraints are ignored by this allocator).
  Methods in jdk.incubator.foreign with parameters of type SegmentAllocator
  Modifier and Type
  Method
  Description
  `MethodHandle`
  CLinker.`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.
  `MemorySegment`
  CLinker.VaList.`vargAsSegment(MemoryLayout layout, SegmentAllocator allocator)`
  Reads the next value as a `MemorySegment`, and advances this va list's position.