java.lang.Object
org.cojen.tupl.io.UnsafeAccess
Utility for accessing the unsupported Unsafe class.
-
Method Summary
Modifier and TypeMethodDescriptionstatic longalloc(int size) Allocate native memory.static longalloc(int size, boolean aligned) Allocate native memory.static longcalloc(int size, boolean aligned) Allocate native memory, zero filled.static voidcopy(byte[] src, int srcOffset, long dstPtr, long len) Copy to native memory.static voidcopy(long srcPtr, byte[] dst, int dstOffset, long len) Copy from native memory.static voidcopy(long srcPtr, long dstPtr, long len) Copy native memory.static voidfill(long ptr, long len, byte value) Fill a range of native memory.static voidfree(long ptr) Free allocated native memory.static sun.misc.Unsafeobtain()static sun.misc.Unsafe
-
Method Details
-
tryObtain
public static sun.misc.Unsafe tryObtain()- Returns:
- null if not supported
-
obtain
- Throws:
UnsupportedOperationException- if not supported
-
alloc
public static long alloc(int size) Allocate native memory. -
alloc
public static long alloc(int size, boolean aligned) Allocate native memory. -
calloc
public static long calloc(int size, boolean aligned) Allocate native memory, zero filled. -
fill
public static void fill(long ptr, long len, byte value) Fill a range of native memory. -
copy
public static void copy(long srcPtr, long dstPtr, long len) Copy native memory. -
copy
public static void copy(byte[] src, int srcOffset, long dstPtr, long len) Copy to native memory. -
copy
public static void copy(long srcPtr, byte[] dst, int dstOffset, long len) Copy from native memory. -
free
public static void free(long ptr) Free allocated native memory.
-