com.sun.jna
public class Memory extends Pointer
Pointer to memory obtained from the native heap via a
call to malloc.
In some cases it might be necessary to use memory obtained from
malloc. For example, Memory helps
accomplish the following idiom:
void *buf = malloc(BUF_LEN * sizeof(char)); call_some_function(buf); free(buf);
The Memory method will free allocated memory when this object is no longer referenced.
See Also: Pointer
| Field Summary | |
|---|---|
| protected long | size |
| Constructor Summary | |
|---|---|
| Memory(long size)
Allocate space in the native heap via a call to C's malloc.
| |
| protected | Memory() |
| Method Summary | |
|---|---|
| Memory | align(int byteBoundary) Provide a view onto this structure with the given alignment. |
| protected void | boundsCheck(long off, long sz)
Check that indirection won't cause us to write outside the
malloc'ed space.
|
| void | clear() Zero the full extent of this memory region. |
| protected void | finalize() |
| protected static void | free(long ptr)
Call the real native free |
| byte | getByte(long offset)
Indirect the native pointer to malloc space, a la
Pointer.getByte. |
| ByteBuffer | getByteBuffer(long offset, long length)
Get a ByteBuffer mapped to a portion of this memory.
|
| char | getChar(long offset)
Indirect the native pointer to malloc space, a la
Pointer.getByte. |
| double | getDouble(long offset)
Indirect the native pointer to malloc space, a la
Pointer.getDouble. |
| float | getFloat(long offset)
Indirect the native pointer to malloc space, a la
Pointer.getFloat. |
| int | getInt(long offset)
Indirect the native pointer to malloc space, a la
Pointer.getInt. |
| long | getLong(long offset)
Indirect the native pointer to malloc space, a la
Pointer.getLong. |
| Pointer | getPointer(long offset)
Indirect the native pointer to malloc space, a la
Pointer.getPointer. |
| short | getShort(long offset)
Indirect the native pointer to malloc space, a la
Pointer.getShort. |
| long | getSize() |
| String | getString(long offset, boolean wide)
Indirect the native pointer to malloc space, a la
Pointer.getString. |
| boolean | isValid() Returns false if the memory has been freed. |
| protected static long | malloc(long size)
Call the real native malloc |
| static void | purge() Force cleanup of memory that has associated NIO Buffers which have
been GC'd. |
| void | read(long bOff, byte[] buf, int index, int length)
Indirect the native pointer to malloc space, a la
Pointer.read. |
| void | read(long bOff, short[] buf, int index, int length)
Indirect the native pointer to malloc space, a la
Pointer.read. |
| void | read(long bOff, char[] buf, int index, int length)
Indirect the native pointer to malloc space, a la
Pointer.read. |
| void | read(long bOff, int[] buf, int index, int length)
Indirect the native pointer to malloc space, a la
Pointer.read. |
| void | read(long bOff, long[] buf, int index, int length)
Indirect the native pointer to malloc space, a la
Pointer.read. |
| void | read(long bOff, float[] buf, int index, int length)
Indirect the native pointer to malloc space, a la
Pointer.read. |
| void | read(long bOff, double[] buf, int index, int length)
Indirect the native pointer to malloc space, a la
Pointer.read. |
| void | setByte(long offset, byte value)
Indirect the native pointer to malloc space, a la
Pointer.setByte. |
| void | setChar(long offset, char value)
Indirect the native pointer to malloc space, a la
Pointer.setChar. |
| void | setDouble(long offset, double value)
Indirect the native pointer to malloc space, a la
Pointer.setDouble. |
| void | setFloat(long offset, float value)
Indirect the native pointer to malloc space, a la
Pointer.setFloat. |
| void | setInt(long offset, int value)
Indirect the native pointer to malloc space, a la
Pointer.setInt. |
| void | setLong(long offset, long value)
Indirect the native pointer to malloc space, a la
Pointer.setLong. |
| void | setPointer(long offset, Pointer value)
Indirect the native pointer to malloc space, a la
Pointer.setPointer. |
| void | setShort(long offset, short value)
Indirect the native pointer to malloc space, a la
Pointer.setShort. |
| void | setString(long offset, String value, boolean wide)
Indirect the native pointer to malloc space, a la
Pointer.setString. |
| Pointer | share(long offset) Provide a view onto this structure from the given offset. |
| Pointer | share(long offset, long sz) Provide a view onto this structure from the given offset. |
| String | toString() |
| void | write(long bOff, byte[] buf, int index, int length)
Indirect the native pointer to malloc space, a la
Pointer.write. |
| void | write(long bOff, short[] buf, int index, int length)
Indirect the native pointer to malloc space, a la
Pointer.write. |
| void | write(long bOff, char[] buf, int index, int length)
Indirect the native pointer to malloc space, a la
Pointer.write. |
| void | write(long bOff, int[] buf, int index, int length)
Indirect the native pointer to malloc space, a la
Pointer.write. |
| void | write(long bOff, long[] buf, int index, int length)
Indirect the native pointer to malloc space, a la
Pointer.write. |
| void | write(long bOff, float[] buf, int index, int length)
Indirect the native pointer to malloc space, a la
Pointer.write. |
| void | write(long bOff, double[] buf, int index, int length)
Indirect the native pointer to malloc space, a la
Pointer.write. |
malloc.
Parameters: size number of bytes of space to allocate
Parameters: byteBoundary Align memory to this number of bytes; should be a power of two.
Throws: IndexOutOfBoundsException if the requested alignment can not be met. IllegalArgumentException if the requested alignment is not a positive power of two.
malloc space, a la
Pointer.getByte. But this method performs a bounds
checks to ensure that the indirection does not cause memory outside the
malloced space to be accessed.
See Also: Pointer
Parameters: offset byte offset from pointer to start the buffer length Length of ByteBuffer
Returns: a direct ByteBuffer that accesses the memory being pointed to,
malloc space, a la
Pointer.getByte. But this method performs a bounds
checks to ensure that the indirection does not cause memory outside the
malloced space to be accessed.
See Also: Pointer
malloc space, a la
Pointer.getDouble. But this method performs a
bounds check to ensure that the indirection does not cause memory
outside the malloced space to be accessed.
See Also: Pointer
malloc space, a la
Pointer.getFloat. But this method performs a bounds
checks to ensure that the indirection does not cause memory outside the
malloced space to be accessed.
See Also: Pointer
malloc space, a la
Pointer.getInt. But this method performs a bounds
checks to ensure that the indirection does not cause memory outside the
malloced space to be accessed.
See Also: Pointer
malloc space, a la
Pointer.getLong. But this method performs a bounds
checks to ensure that the indirection does not cause memory outside the
malloced space to be accessed.
See Also: Pointer
malloc space, a la
Pointer.getPointer. But this method performs
a bounds checks to ensure that the indirection does not cause memory
outside the malloced space to be accessed.
See Also: Pointer
malloc space, a la
Pointer.getShort. But this method performs a bounds
checks to ensure that the indirection does not cause memory outside the
malloced space to be accessed.
See Also: Pointer
malloc space, a la
Pointer.getString. But this method performs a
bounds checks to ensure that the indirection does not cause memory
outside the malloced space to be accessed.
See Also: Pointer
malloc space, a la
Pointer.read. But this method performs a bounds
checks to ensure that the indirection does not cause memory outside the
malloced space to be accessed.
See Also: (long,byte[],int,int)
malloc space, a la
Pointer.read. But this method performs a bounds
checks to ensure that the indirection does not cause memory outside the
malloced space to be accessed.
See Also: (long,short[],int,int)
malloc space, a la
Pointer.read. But this method performs a bounds
checks to ensure that the indirection does not cause memory outside the
malloced space to be accessed.
See Also: (long,char[],int,int)
malloc space, a la
Pointer.read. But this method performs a bounds
checks to ensure that the indirection does not cause memory outside the
malloced space to be accessed.
See Also: (long,int[],int,int)
malloc space, a la
Pointer.read. But this method performs a bounds
checks to ensure that the indirection does not cause memory outside the
malloced space to be accessed.
See Also: (long,long[],int,int)
malloc space, a la
Pointer.read. But this method performs a bounds
checks to ensure that the indirection does not cause memory outside the
malloced space to be accessed.
See Also: (long,float[],int,int)
malloc space, a la
Pointer.read. But this method performs a bounds checks to
ensure that the indirection does not cause memory outside the
malloced space to be accessed.
See Also: (long,double[],int,int)
malloc space, a la
Pointer.setByte. But this method performs a bounds
checks to ensure that the indirection does not cause memory outside the
malloced space to be accessed.
See Also: Pointer
malloc space, a la
Pointer.setChar. But this method performs a bounds
checks to ensure that the indirection does not cause memory outside the
malloced space to be accessed.
See Also: Pointer
malloc space, a la
Pointer.setDouble. But this method performs a
bounds checks to ensure that the indirection does not cause memory
outside the malloced space to be accessed.
See Also: Pointer
malloc space, a la
Pointer.setFloat. But this method performs a bounds
checks to ensure that the indirection does not cause memory outside the
malloced space to be accessed.
See Also: Pointer
malloc space, a la
Pointer.setInt. But this method performs a bounds
checks to ensure that the indirection does not cause memory outside the
malloced space to be accessed.
See Also: Pointer
malloc space, a la
Pointer.setLong. But this method performs a bounds
checks to ensure that the indirection does not cause memory outside the
malloced space to be accessed.
See Also: Pointer
malloc space, a la
Pointer.setPointer. But this method performs
a bounds checks to ensure that the indirection does not cause memory
outside the malloced space to be accessed.
See Also: Pointer
malloc space, a la
Pointer.setShort. But this method performs a bounds
checks to ensure that the indirection does not cause memory outside the
malloced space to be accessed.
See Also: Pointer
malloc space, a la
Pointer.setString. But this method performs a
bounds checks to ensure that the indirection does not cause memory
outside the malloced space to be accessed.
See Also: Pointer
Throws: IndexOutOfBoundsException if the requested memory is outside the allocated bounds.
Throws: IndexOutOfBoundsException if the requested memory is outside the allocated bounds.
malloc space, a la
Pointer.write. But this method performs a bounds
checks to ensure that the indirection does not cause memory outside the
malloced space to be accessed.
See Also: (long,byte[],int,int)
malloc space, a la
Pointer.write. But this method performs a bounds
checks to ensure that the indirection does not cause memory outside the
malloced space to be accessed.
See Also: (long,short[],int,int)
malloc space, a la
Pointer.write. But this method performs a bounds
checks to ensure that the indirection does not cause memory outside the
malloced space to be accessed.
See Also: (long,char[],int,int)
malloc space, a la
Pointer.write. But this method performs a bounds
checks to ensure that the indirection does not cause memory outside the
malloced space to be accessed.
See Also: (long,int[],int,int)
malloc space, a la
Pointer.write. But this method performs a bounds
checks to ensure that the indirection does not cause memory outside the
malloced space to be accessed.
See Also: (long,long[],int,int)
malloc space, a la
Pointer.write. But this method performs a bounds
checks to ensure that the indirection does not cause memory outside the
malloced space to be accessed.
See Also: (long,float[],int,int)
malloc space, a la
Pointer.write. But this method performs a bounds
checks to ensure that the indirection does not cause memory outside the
malloced space to be accessed.
See Also: (long,double[],int,int)