- java.lang.Object
-
- jnr.ffi.Memory
-
public final class Memory extends Object
A utility for allocating memory that can be passed to native functions.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Pointerallocate(Runtime runtime, int size)Allocates a new block of java memory and wraps it in aPointeraccessor.static Pointerallocate(Runtime runtime, NativeType type)Allocates a new block of java memory and wraps it in aPointeraccessor.static Pointerallocate(Runtime runtime, Type type)Allocates a new block of java memory and wraps it in aPointeraccessor.static Pointerallocate(Runtime runtime, TypeAlias type)Allocates a new block of java memory and wraps it in aPointeraccessor.static PointerallocateDirect(Runtime runtime, int size)Allocates a new block of native memory and wraps it in aPointeraccessor.static PointerallocateDirect(Runtime runtime, int size, boolean clear)Allocates a new block of native memory and wraps it in aPointeraccessor.static PointerallocateDirect(Runtime runtime, long size)Allocates a new block of native memory and wraps it in aPointeraccessor.static PointerallocateDirect(Runtime runtime, long size, boolean clear)Allocates a new block of native memory and wraps it in aPointeraccessor.static PointerallocateDirect(Runtime runtime, NativeType type)Allocates a new block of native memory and wraps it in aPointeraccessor.static PointerallocateDirect(Runtime runtime, TypeAlias type)Allocates a new block of native memory and wraps it in aPointeraccessor.static PointerallocateTemporary(Runtime runtime, NativeType type)Allocates a new block of transient native memory and wraps it in aPointeraccessor.static PointerallocateTemporary(Runtime runtime, NativeType type, boolean clear)Allocates a new block of transient native memory and wraps it in aPointeraccessor.static PointerallocateTemporary(Runtime runtime, TypeAlias type)Allocates a new block of transient native memory and wraps it in aPointeraccessor.
-
-
-
Method Detail
-
allocate
public static Pointer allocate(Runtime runtime, int size)
Allocates a new block of java memory and wraps it in aPointeraccessor.- Parameters:
runtime- The current runtime.size- The size in bytes of memory to allocate.- Returns:
- a
Pointerinstance that can access the memory.
-
allocate
public static Pointer allocate(Runtime runtime, NativeType type)
Allocates a new block of java memory and wraps it in aPointeraccessor.- Parameters:
runtime- The current runtime.type- The native type to allocate memory for.- Returns:
- a
Pointerinstance that can access the memory.
-
allocate
public static Pointer allocate(Runtime runtime, Type type)
Allocates a new block of java memory and wraps it in aPointeraccessor.- Parameters:
runtime- The current runtime.type- The type to allocate memory for.- Returns:
- a
Pointerinstance that can access the memory.
-
allocate
public static Pointer allocate(Runtime runtime, TypeAlias type)
Allocates a new block of java memory and wraps it in aPointeraccessor.- Parameters:
runtime- The current runtime.type- The type alias to allocate memory for.- Returns:
- a
Pointerinstance that can access the memory.
-
allocateDirect
public static Pointer allocateDirect(Runtime runtime, int size)
Allocates a new block of native memory and wraps it in aPointeraccessor.- Parameters:
runtime- The current runtime.size- The size in bytes of memory to allocate.- Returns:
- a
Pointerinstance that can access the memory.
-
allocateDirect
public static Pointer allocateDirect(Runtime runtime, long size)
Allocates a new block of native memory and wraps it in aPointeraccessor.- Parameters:
runtime- The current runtime.size- The size in bytes of memory to allocate.- Returns:
- a
Pointerinstance that can access the memory.
-
allocateDirect
public static Pointer allocateDirect(Runtime runtime, NativeType type)
Allocates a new block of native memory and wraps it in aPointeraccessor.- Parameters:
runtime- The current runtime.type- The native type to allocate memory for.- Returns:
- a
Pointerinstance that can access the memory.
-
allocateDirect
public static Pointer allocateDirect(Runtime runtime, TypeAlias type)
Allocates a new block of native memory and wraps it in aPointeraccessor.- Parameters:
runtime- The current runtime.type- The type alias to allocate memory for.- Returns:
- a
Pointerinstance that can access the memory.
-
allocateDirect
public static Pointer allocateDirect(Runtime runtime, int size, boolean clear)
Allocates a new block of native memory and wraps it in aPointeraccessor.- Parameters:
runtime- The current runtime.size- The size in bytes of memory to allocate.clear- Whether the memory contents should be cleared, or left as random data.- Returns:
- a
Pointerinstance that can access the memory.
-
allocateDirect
public static Pointer allocateDirect(Runtime runtime, long size, boolean clear)
Allocates a new block of native memory and wraps it in aPointeraccessor.- Parameters:
runtime- The current runtime.size- The size in bytes of memory to allocate.clear- Whether the memory contents should be cleared, or left as random data.- Returns:
- a
Pointerinstance that can access the memory.
-
allocateTemporary
public static Pointer allocateTemporary(Runtime runtime, NativeType type)
Allocates a new block of transient native memory and wraps it in aPointeraccessor. The memory returned by this method should not be passed to native methods that store the address for later use, as it may change each time it is passed to native code.- Parameters:
runtime- The current runtime.type- The native type to allocate memory for.- Returns:
- a
Pointerinstance that can access the memory.
-
allocateTemporary
public static Pointer allocateTemporary(Runtime runtime, TypeAlias type)
Allocates a new block of transient native memory and wraps it in aPointeraccessor. The memory returned by this method should not be passed to native methods that store the address for later use, as it may change each time it is passed to native code.- Parameters:
runtime- The current runtime.type- The type alias to allocate memory for.- Returns:
- a
Pointerinstance that can access the memory.
-
allocateTemporary
public static Pointer allocateTemporary(Runtime runtime, NativeType type, boolean clear)
Allocates a new block of transient native memory and wraps it in aPointeraccessor. The memory returned by this method should not be passed to native methods that store the address for later use, as it may change each time it is passed to native code.- Parameters:
runtime- The current runtime.type- The native type to allocate memory for.clear- Whether the memory contents should be cleared, or left as random data.- Returns:
- a
Pointerinstance that can access the memory.
-
-