io.vproxy.pni.impl.NoCloseArenaAllocator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pni-api-jdk22 Show documentation
Show all versions of pni-api-jdk22 Show documentation
panama native interface pni-api-jdk22
The newest version!
package io.vproxy.pni.impl;
import io.vproxy.pni.Allocator;
import java.lang.foreign.Arena;
import java.lang.foreign.MemorySegment;
public class NoCloseArenaAllocator extends AbstractAllocator implements Allocator {
private final Arena arena;
public NoCloseArenaAllocator(Arena arena) {
this.arena = arena;
}
@Override
public MemorySegment allocate(long size) {
return arena.allocate(size);
}
@Override
public MemorySegment allocate(long size, int alignment) {
return arena.allocate(size, alignment);
}
public static final NoCloseArenaAllocator GLOBAL = new NoCloseArenaAllocator(Arena.global());
}