Top Description Inners Fields Constructors Methods
com.sun.jna

public Class Memory

extends Pointer
Class Inheritance
Known Direct Subclasses
com.sun.jna.Memory.SharedMemory, com.sun.jna.StringArray, com.sun.jna.Function.PointerArray
Imports
java.nio.ByteBuffer

A 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 finalize method will free allocated memory when this object is no longer referenced.

Authors
Sheng Liang, originator, Todd Fast, suitability modifications, Timothy Wall
See Also
Pointer

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
Memory.SharedMemory

Provide a view into the original memory.

Field Summary

Modifier and TypeField and Description
protected long
Inherited from com.sun.jna.Pointer:
NULLpeerSIZE

Constructor Summary

AccessConstructor and Description
public
Memory(long
number of bytes of space to allocate
size
)

Allocate space in the native heap via a call to C's malloc.

protected

Method Summary

Modifier and TypeMethod and Description
public Pointer
align(int
Align memory to this number of bytes; should be a power of two.
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.

public void
clear()

Zero the full extent of this memory region.

protected void
finalize()

Overrides java.lang.Object.finalize.

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
pack-priv static native void
free(long ptr)

Call the real native free

public byte
getByte(long
offset from pointer to perform the indirection
offset
)

Overrides com.sun.jna.Pointer.getByte.

Indirect the native pointer to malloc space, a la Pointer.getByte.
public ByteBuffer

Returns:

a direct ByteBuffer that accesses the memory being pointed to,
getByteBuffer
(long
byte offset from pointer to start the buffer
offset
,
long
Length of ByteBuffer
length
)

Overrides com.sun.jna.Pointer.getByteBuffer.

Get a ByteBuffer mapped to a portion of this memory.
public char
getChar(long
offset from pointer to perform the indirection
offset
)

Overrides com.sun.jna.Pointer.getChar.

Indirect the native pointer to malloc space, a la Pointer.getByte.
public double
getDouble(long
byte offset from pointer to perform the indirection
offset
)

Overrides com.sun.jna.Pointer.getDouble.

Indirect the native pointer to malloc space, a la Pointer.getDouble.
public float
getFloat(long
byte offset from pointer to perform the indirection
offset
)

Overrides com.sun.jna.Pointer.getFloat.

Indirect the native pointer to malloc space, a la Pointer.getFloat.
public int
getInt(long
byte offset from pointer to perform the indirection
offset
)

Overrides com.sun.jna.Pointer.getInt.

Indirect the native pointer to malloc space, a la Pointer.getInt.
public long
getLong(long
byte offset from pointer to perform the indirection
offset
)

Overrides com.sun.jna.Pointer.getLong.

Indirect the native pointer to malloc space, a la Pointer.getLong.
public Pointer
getPointer(long
byte offset from pointer to perform the indirection
offset
)

Overrides com.sun.jna.Pointer.getPointer.

Indirect the native pointer to malloc space, a la Pointer.getPointer.
public short
getShort(long
byte offset from pointer to perform the indirection
offset
)

Overrides com.sun.jna.Pointer.getShort.

Indirect the native pointer to malloc space, a la Pointer.getShort.
public long
public String
getString(long
byte offset from pointer to obtain the native string v * @param wide whether to convert from a wide or standard C string
offset
,
boolean wide)

Overrides com.sun.jna.Pointer.getString.

Indirect the native pointer to malloc space, a la Pointer.getString.
public boolean
isValid()

Returns false if the memory has been freed.

pack-priv static native long
malloc(long size)

Call the real native malloc

public void
read(long
byte offset from pointer into which data is copied
bOff
,
byte[]
byte array into which data is copied
buf
,
int
array index from which to start copying
index
,
int
number of elements from native pointer that must be copied
length
)

Overrides com.sun.jna.Pointer.read.

Indirect the native pointer to malloc space, a la Pointer.read.
public void
read(long
byte offset from pointer from which data is copied
bOff
,
short[]
short array into which data is copied
buf
,
int
array index to which data is copied
index
,
int
number of elements from native pointer that must be copied
length
)

Overrides com.sun.jna.Pointer.read.

Indirect the native pointer to malloc space, a la Pointer.read.
public void
read(long
byte offset from pointer from which data is copied
bOff
,
char[]
char array into which data is copied
buf
,
int
array index to which data is copied
index
,
int
number of elements from native pointer that must be copied
length
)

Overrides com.sun.jna.Pointer.read.

Indirect the native pointer to malloc space, a la Pointer.read.
public void
read(long
byte offset from pointer from which data is copied
bOff
,
int[]
int array into which data is copied
buf
,
int
array index to which data is copied
index
,
int
number of elements from native pointer that must be copied
length
)

Overrides com.sun.jna.Pointer.read.

Indirect the native pointer to malloc space, a la Pointer.read.
public void
read(long
byte offset from pointer from which data is copied
bOff
,
long[]
long array into which data is copied
buf
,
int
array index to which data is copied
index
,
int
number of elements from native pointer that must be copied
length
)

Overrides com.sun.jna.Pointer.read.

Indirect the native pointer to malloc space, a la Pointer.read.
public void
read(long
byte offset from pointer from which data is copied
bOff
,
float[]
float array into which data is copied
buf
,
int
array index to which data is copied
index
,
int
number of elements from native pointer that must be copied
length
)

Overrides com.sun.jna.Pointer.read.

Indirect the native pointer to malloc space, a la Pointer.read.
public void
read(long
byte offset from pointer from which data is copied
bOff
,
double[]
double array into which data is copied
buf
,
int
array index to which data is copied
index
,
int
number of elements from native pointer that must be copied
length
)

Overrides com.sun.jna.Pointer.read.

Indirect the native pointer to malloc space, a la Pointer.read.
public void
setByte(long
byte offset from pointer at which value must be set
offset
,
byte
byte value to set
value
)

Overrides com.sun.jna.Pointer.setByte.

Indirect the native pointer to malloc space, a la Pointer.setByte.
public void
setChar(long
byte offset from pointer at which value must be set
offset
,
char
char value to set
value
)

Overrides com.sun.jna.Pointer.setChar.

Indirect the native pointer to malloc space, a la Pointer.setChar.
public void
setDouble(long
byte offset from pointer at which value must be set
offset
,
double
double value to set
value
)

Overrides com.sun.jna.Pointer.setDouble.

Indirect the native pointer to malloc space, a la Pointer.setDouble.
public void
setFloat(long
byte offset from pointer at which value must be set
offset
,
float
float value to set
value
)

Overrides com.sun.jna.Pointer.setFloat.

Indirect the native pointer to malloc space, a la Pointer.setFloat.
public void
setInt(long
byte offset from pointer at which value must be set
offset
,
int
int value to set
value
)

Overrides com.sun.jna.Pointer.setInt.

Indirect the native pointer to malloc space, a la Pointer.setInt.
public void
setLong(long
byte offset from pointer at which value must be set
offset
,
long
long value to set
value
)

Overrides com.sun.jna.Pointer.setLong.

Indirect the native pointer to malloc space, a la Pointer.setLong.
public void
setPointer(long
byte offset from pointer at which value must be set
offset
,
Pointer
Pointer holding the actual pointer value to set, which may be null to indicate a NULL pointer.
value
)

Overrides com.sun.jna.Pointer.setPointer.

Indirect the native pointer to malloc space, a la Pointer.setPointer.
public void
setShort(long
byte offset from pointer at which value must be set
offset
,
short
short value to set
value
)

Overrides com.sun.jna.Pointer.setShort.

Indirect the native pointer to malloc space, a la Pointer.setShort.
public void
setString(long
byte offset from pointer at which characters in value must be set
offset
,
String
java.lang.String value to set
value
,
boolean
whether to write the native string as an array of wchar_t. If false, writes as a NUL-terminated array of char using the default platform encoding.
wide
)

Overrides com.sun.jna.Pointer.setString.

Indirect the native pointer to malloc space, a la Pointer.setString.
public Pointer
share(long offset)

Overrides com.sun.jna.Pointer.share.

Provide a view onto this structure from the given offset.
public Pointer
share(long offset, long sz)

Overrides com.sun.jna.Pointer.share.

Provide a view onto this structure from the given offset.
public String
toString()

Overrides com.sun.jna.Pointer.toString.

Returns a string representation of the object.
public void
write(long
byte offset from pointer into which data is copied
bOff
,
byte[]
byte array from which to copy
buf
,
int
array index from which to start copying
index
,
int
number of elements from buf that must be copied
length
)

Overrides com.sun.jna.Pointer.write.

Indirect the native pointer to malloc space, a la Pointer.write.
public void
write(long
byte offset from pointer into which data is copied
bOff
,
short[]
short array from which to copy
buf
,
int
array index from which to start copying
index
,
int
number of elements from buf that must be copied
length
)

Overrides com.sun.jna.Pointer.write.

Indirect the native pointer to malloc space, a la Pointer.write.
public void
write(long
byte offset from pointer into which data is copied
bOff
,
char[]
char array from which to copy
buf
,
int
array index from which to start copying
index
,
int
number of elements from buf that must be copied
length
)

Overrides com.sun.jna.Pointer.write.

Indirect the native pointer to malloc space, a la Pointer.write.
public void
write(long
byte offset from pointer into which data is copied
bOff
,
int[]
int array from which to copy
buf
,
int
array index from which to start copying
index
,
int
number of elements from buf that must be copied
length
)

Overrides com.sun.jna.Pointer.write.

Indirect the native pointer to malloc space, a la Pointer.write.
public void
write(long
byte offset from pointer into which data is copied
bOff
,
long[]
long array from which to copy
buf
,
int
array index from which to start copying
index
,
int
number of elements from buf that must be copied
length
)

Overrides com.sun.jna.Pointer.write.

Indirect the native pointer to malloc space, a la Pointer.write.
public void
write(long
byte offset from pointer into which data is copied
bOff
,
float[]
float array from which to copy
buf
,
int
array index from which to start copying
index
,
int
number of elements from buf that must be copied
length
)

Overrides com.sun.jna.Pointer.write.

Indirect the native pointer to malloc space, a la Pointer.write.
public void
write(long
byte offset from pointer into which data is copied
bOff
,
double[]
double array from which to copy
buf
,
int
array index from which to start copying
index
,
int
number of elements from buf that must be copied
length
)

Overrides com.sun.jna.Pointer.write.

Indirect the native pointer to malloc space, a la Pointer.write.
Inherited from com.sun.jna.Pointer:
clearcreateConstantequalsgetByteArraygetCharArraygetDoubleArraygetFloatArraygetIntArraygetLongArraygetNativeLonggetPointerArraygetShortArraygetStringhashCodeindexOfreadsetMemorysetNativeLongsetStringwrite

Field Detail

sizeback to summary
protected long size

Constructor Detail

Memoryback to summary
public Memory(long size)

Allocate space in the native heap via a call to C's malloc.

Parameters
size:long

number of bytes of space to allocate

Memoryback to summary
protected Memory()

Method Detail

alignback to summary
public Pointer align(int byteBoundary)

Provide a view onto this structure with the given alignment.

Parameters
byteBoundary:int

Align memory to this number of bytes; should be a power of two.

Exceptions
IndexOutOfBoundsException:
if the requested alignment can not be met.
IllegalArgumentException:
if the requested alignment is not a positive power of two.
boundsCheckback to summary
protected void boundsCheck(long off, long sz)

Check that indirection won't cause us to write outside the malloc'ed space.

clearback to summary
public void clear()

Zero the full extent of this memory region.

finalizeback to summary
protected void finalize()

Overrides java.lang.Object.finalize.

Doc from java.lang.Object.finalize.

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. A subclass overrides the finalize method to dispose of system resources or to perform other cleanup.

When running in a Java virtual machine in which finalization has been disabled or removed, the garbage collector will never call finalize(). In a Java virtual machine in which finalization is enabled, the garbage collector might call finalize only after an indefinite delay.

The general contract of finalize is that it is invoked if and when the Java virtual machine has determined that there is no longer any means by which this object can be accessed by any thread that has not yet died, except as a result of an action taken by the finalization of some other object or class which is ready to be finalized. The finalize method may take any action, including making this object available again to other threads; the usual purpose of finalize, however, is to perform cleanup actions before the object is irrevocably discarded. For example, the finalize method for an object that represents an input/output connection might perform explicit I/O transactions to break the connection before the object is permanently discarded.

The finalize method of class Object performs no special action; it simply returns normally. Subclasses of Object may override this definition.

The Java programming language does not guarantee which thread will invoke the finalize method for any given object. It is guaranteed, however, that the thread that invokes finalize will not be holding any user-visible synchronization locks when finalize is invoked. If an uncaught exception is thrown by the finalize method, the exception is ignored and finalization of that object terminates.

After the finalize method has been invoked for an object, no further action is taken until the Java virtual machine has again determined that there is no longer any means by which this object can be accessed by any thread that has not yet died, including possible actions by other objects or classes which are ready to be finalized, at which point the object may be discarded.

The finalize method is never invoked more than once by a Java virtual machine for any given object.

Any exception thrown by the finalize method causes the finalization of this object to be halted, but is otherwise ignored.

freeback to summary
pack-priv static native void free(long ptr)

Call the real native free

getByteback to summary
public byte getByte(long offset)

Overrides com.sun.jna.Pointer.getByte.

Indirect the native pointer 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.

Parameters
offset:long

Doc from com.sun.jna.Pointer.getByte.

offset from pointer to perform the indirection

Returns:byte

Doc from com.sun.jna.Pointer.getByte.

the byte value being pointed to

See Also
Pointer#getByte(long)
getByteBufferback to summary
public ByteBuffer getByteBuffer(long offset, long length)

Overrides com.sun.jna.Pointer.getByteBuffer.

Get a ByteBuffer mapped to a portion of this memory.

Parameters
offset:long

byte offset from pointer to start the buffer

length:long

Length of ByteBuffer

Returns:ByteBuffer

a direct ByteBuffer that accesses the memory being pointed to,

getCharback to summary
public char getChar(long offset)

Overrides com.sun.jna.Pointer.getChar.

Indirect the native pointer 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.

Parameters
offset:long

Doc from com.sun.jna.Pointer.getChar.

offset from pointer to perform the indirection

Returns:char

Doc from com.sun.jna.Pointer.getChar.

the wchar_t value being pointed to

See Also
Pointer#getByte(long)
getDoubleback to summary
public double getDouble(long offset)

Overrides com.sun.jna.Pointer.getDouble.

Indirect the native pointer to 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.

Parameters
offset:long

Doc from com.sun.jna.Pointer.getDouble.

byte offset from pointer to perform the indirection

Returns:double

Doc from com.sun.jna.Pointer.getDouble.

the double value being pointed to

See Also
Pointer#getDouble(long)
getFloatback to summary
public float getFloat(long offset)

Overrides com.sun.jna.Pointer.getFloat.

Indirect the native pointer to 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.

Parameters
offset:long

Doc from com.sun.jna.Pointer.getFloat.

byte offset from pointer to perform the indirection

Returns:float

Doc from com.sun.jna.Pointer.getFloat.

the float value being pointed to

See Also
Pointer#getFloat(long)
getIntback to summary
public int getInt(long offset)

Overrides com.sun.jna.Pointer.getInt.

Indirect the native pointer to 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.

Parameters
offset:long

Doc from com.sun.jna.Pointer.getInt.

byte offset from pointer to perform the indirection

Returns:int

Doc from com.sun.jna.Pointer.getInt.

the int value being pointed to

See Also
Pointer#getInt(long)
getLongback to summary
public long getLong(long offset)

Overrides com.sun.jna.Pointer.getLong.

Indirect the native pointer to 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.

Parameters
offset:long

Doc from com.sun.jna.Pointer.getLong.

byte offset from pointer to perform the indirection

Returns:long

Doc from com.sun.jna.Pointer.getLong.

the long value being pointed to

See Also
Pointer#getLong(long)
getPointerback to summary
public Pointer getPointer(long offset)

Overrides com.sun.jna.Pointer.getPointer.

Indirect the native pointer to 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.

Parameters
offset:long

Doc from com.sun.jna.Pointer.getPointer.

byte offset from pointer to perform the indirection

Returns:Pointer

Doc from com.sun.jna.Pointer.getPointer.

a Pointer equivalent of the pointer value being pointed to, or null if the pointer value is NULL;

See Also
Pointer#getPointer(long)
getShortback to summary
public short getShort(long offset)

Overrides com.sun.jna.Pointer.getShort.

Indirect the native pointer to 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.

Parameters
offset:long

Doc from com.sun.jna.Pointer.getShort.

byte offset from pointer to perform the indirection

Returns:short

Doc from com.sun.jna.Pointer.getShort.

the short value being pointed to

See Also
Pointer#getShort(long)
getSizeback to summary
public long getSize()
getStringback to summary
public String getString(long offset, boolean wide)

Overrides com.sun.jna.Pointer.getString.

Indirect the native pointer to 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.

Parameters
offset:long

Doc from com.sun.jna.Pointer.getString.

byte offset from pointer to obtain the native string v * @param wide whether to convert from a wide or standard C string

Returns:String

Doc from com.sun.jna.Pointer.getString.

the String value being pointed to

See Also
Pointer#getString(long, boolean)
isValidback to summary
public boolean isValid()

Returns false if the memory has been freed.

mallocback to summary
pack-priv static native long malloc(long size)

Call the real native malloc

readback to summary
public void read(long bOff, byte[] buf, int index, int length)

Overrides com.sun.jna.Pointer.read.

Indirect the native pointer to 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.

Parameters
bOff:long

Doc from com.sun.jna.Pointer.read.

byte offset from pointer into which data is copied

buf:byte[]

Doc from com.sun.jna.Pointer.read.

byte array into which data is copied

index:int

Doc from com.sun.jna.Pointer.read.

array index from which to start copying

length:int

Doc from com.sun.jna.Pointer.read.

number of elements from native pointer that must be copied

See Also
Pointer#read(long, byte[], int, int)
readback to summary
public void read(long bOff, short[] buf, int index, int length)

Overrides com.sun.jna.Pointer.read.

Indirect the native pointer to 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.

Parameters
bOff:long

Doc from com.sun.jna.Pointer.read.

byte offset from pointer from which data is copied

buf:short[]

Doc from com.sun.jna.Pointer.read.

short array into which data is copied

index:int

Doc from com.sun.jna.Pointer.read.

array index to which data is copied

length:int

Doc from com.sun.jna.Pointer.read.

number of elements from native pointer that must be copied

See Also
Pointer#read(long, short[], int, int)
readback to summary
public void read(long bOff, char[] buf, int index, int length)

Overrides com.sun.jna.Pointer.read.

Indirect the native pointer to 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.

Parameters
bOff:long

Doc from com.sun.jna.Pointer.read.

byte offset from pointer from which data is copied

buf:char[]

Doc from com.sun.jna.Pointer.read.

char array into which data is copied

index:int

Doc from com.sun.jna.Pointer.read.

array index to which data is copied

length:int

Doc from com.sun.jna.Pointer.read.

number of elements from native pointer that must be copied

See Also
Pointer#read(long, char[], int, int)
readback to summary
public void read(long bOff, int[] buf, int index, int length)

Overrides com.sun.jna.Pointer.read.

Indirect the native pointer to 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.

Parameters
bOff:long

Doc from com.sun.jna.Pointer.read.

byte offset from pointer from which data is copied

buf:int[]

Doc from com.sun.jna.Pointer.read.

int array into which data is copied

index:int

Doc from com.sun.jna.Pointer.read.

array index to which data is copied

length:int

Doc from com.sun.jna.Pointer.read.

number of elements from native pointer that must be copied

See Also
Pointer#read(long, int[], int, int)
readback to summary
public void read(long bOff, long[] buf, int index, int length)

Overrides com.sun.jna.Pointer.read.

Indirect the native pointer to 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.

Parameters
bOff:long

Doc from com.sun.jna.Pointer.read.

byte offset from pointer from which data is copied

buf:long[]

Doc from com.sun.jna.Pointer.read.

long array into which data is copied

index:int

Doc from com.sun.jna.Pointer.read.

array index to which data is copied

length:int

Doc from com.sun.jna.Pointer.read.

number of elements from native pointer that must be copied

See Also
Pointer#read(long, long[], int, int)
readback to summary
public void read(long bOff, float[] buf, int index, int length)

Overrides com.sun.jna.Pointer.read.

Indirect the native pointer to 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.

Parameters
bOff:long

Doc from com.sun.jna.Pointer.read.

byte offset from pointer from which data is copied

buf:float[]

Doc from com.sun.jna.Pointer.read.

float array into which data is copied

index:int

Doc from com.sun.jna.Pointer.read.

array index to which data is copied

length:int

Doc from com.sun.jna.Pointer.read.

number of elements from native pointer that must be copied

See Also
Pointer#read(long, float[], int, int)
readback to summary
public void read(long bOff, double[] buf, int index, int length)

Overrides com.sun.jna.Pointer.read.

Indirect the native pointer to 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.

Parameters
bOff:long

Doc from com.sun.jna.Pointer.read.

byte offset from pointer from which data is copied

buf:double[]

Doc from com.sun.jna.Pointer.read.

double array into which data is copied

index:int

Doc from com.sun.jna.Pointer.read.

array index to which data is copied

length:int

Doc from com.sun.jna.Pointer.read.

number of elements from native pointer that must be copied

See Also
Pointer#read(long, double[], int, int)
setByteback to summary
public void setByte(long offset, byte value)

Overrides com.sun.jna.Pointer.setByte.

Indirect the native pointer to 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.

Parameters
offset:long

Doc from com.sun.jna.Pointer.setByte.

byte offset from pointer at which value must be set

value:byte

Doc from com.sun.jna.Pointer.setByte.

byte value to set

See Also
Pointer#setByte
setCharback to summary
public void setChar(long offset, char value)

Overrides com.sun.jna.Pointer.setChar.

Indirect the native pointer to 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.

Parameters
offset:long

Doc from com.sun.jna.Pointer.setChar.

byte offset from pointer at which value must be set

value:char

Doc from com.sun.jna.Pointer.setChar.

char value to set

See Also
Pointer#setChar
setDoubleback to summary
public void setDouble(long offset, double value)

Overrides com.sun.jna.Pointer.setDouble.

Indirect the native pointer to 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.

Parameters
offset:long

Doc from com.sun.jna.Pointer.setDouble.

byte offset from pointer at which value must be set

value:double

Doc from com.sun.jna.Pointer.setDouble.

double value to set

See Also
Pointer#setDouble
setFloatback to summary
public void setFloat(long offset, float value)

Overrides com.sun.jna.Pointer.setFloat.

Indirect the native pointer to 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.

Parameters
offset:long

Doc from com.sun.jna.Pointer.setFloat.

byte offset from pointer at which value must be set

value:float

Doc from com.sun.jna.Pointer.setFloat.

float value to set

See Also
Pointer#setFloat
setIntback to summary
public void setInt(long offset, int value)

Overrides com.sun.jna.Pointer.setInt.

Indirect the native pointer to 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.

Parameters
offset:long

Doc from com.sun.jna.Pointer.setInt.

byte offset from pointer at which value must be set

value:int

Doc from com.sun.jna.Pointer.setInt.

int value to set

See Also
Pointer#setInt
setLongback to summary
public void setLong(long offset, long value)

Overrides com.sun.jna.Pointer.setLong.

Indirect the native pointer to 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.

Parameters
offset:long

Doc from com.sun.jna.Pointer.setLong.

byte offset from pointer at which value must be set

value:long

Doc from com.sun.jna.Pointer.setLong.

long value to set

See Also
Pointer#setLong
setPointerback to summary
public void setPointer(long offset, Pointer value)

Overrides com.sun.jna.Pointer.setPointer.

Indirect the native pointer to 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.

Parameters
offset:long

Doc from com.sun.jna.Pointer.setPointer.

byte offset from pointer at which value must be set

value:Pointer

Doc from com.sun.jna.Pointer.setPointer.

Pointer holding the actual pointer value to set, which may be null to indicate a NULL pointer.

See Also
Pointer#setPointer
setShortback to summary
public void setShort(long offset, short value)

Overrides com.sun.jna.Pointer.setShort.

Indirect the native pointer to 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.

Parameters
offset:long

Doc from com.sun.jna.Pointer.setShort.

byte offset from pointer at which value must be set

value:short

Doc from com.sun.jna.Pointer.setShort.

short value to set

See Also
Pointer#setShort
setStringback to summary
public void setString(long offset, String value, boolean wide)

Overrides com.sun.jna.Pointer.setString.

Indirect the native pointer to 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.

Parameters
offset:long

Doc from com.sun.jna.Pointer.setString.

byte offset from pointer at which characters in value must be set

value:String

Doc from com.sun.jna.Pointer.setString.

java.lang.String value to set

wide:boolean

Doc from com.sun.jna.Pointer.setString.

whether to write the native string as an array of wchar_t. If false, writes as a NUL-terminated array of char using the default platform encoding.

See Also
Pointer#setString(long, String, boolean)
shareback to summary
public Pointer share(long offset)

Overrides com.sun.jna.Pointer.share.

Provide a view onto this structure from the given offset. The returned Pointer will have the same size as the original, reduced by the offset.

Exceptions
IndexOutOfBoundsException:
if the requested memory is outside the allocated bounds.
shareback to summary
public Pointer share(long offset, long sz)

Overrides com.sun.jna.Pointer.share.

Provide a view onto this structure from the given offset.

Exceptions
IndexOutOfBoundsException:
if the requested memory is outside the allocated bounds.
toStringback to summary
public String toString()

Overrides com.sun.jna.Pointer.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

writeback to summary
public void write(long bOff, byte[] buf, int index, int length)

Overrides com.sun.jna.Pointer.write.

Indirect the native pointer to 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.

Parameters
bOff:long

Doc from com.sun.jna.Pointer.write.

byte offset from pointer into which data is copied

buf:byte[]

Doc from com.sun.jna.Pointer.write.

byte array from which to copy

index:int

Doc from com.sun.jna.Pointer.write.

array index from which to start copying

length:int

Doc from com.sun.jna.Pointer.write.

number of elements from buf that must be copied

See Also
Pointer#write(long, byte[], int, int)
writeback to summary
public void write(long bOff, short[] buf, int index, int length)

Overrides com.sun.jna.Pointer.write.

Indirect the native pointer to 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.

Parameters
bOff:long

Doc from com.sun.jna.Pointer.write.

byte offset from pointer into which data is copied

buf:short[]

Doc from com.sun.jna.Pointer.write.

short array from which to copy

index:int

Doc from com.sun.jna.Pointer.write.

array index from which to start copying

length:int

Doc from com.sun.jna.Pointer.write.

number of elements from buf that must be copied

See Also
Pointer#write(long, short[], int, int)
writeback to summary
public void write(long bOff, char[] buf, int index, int length)

Overrides com.sun.jna.Pointer.write.

Indirect the native pointer to 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.

Parameters
bOff:long

Doc from com.sun.jna.Pointer.write.

byte offset from pointer into which data is copied

buf:char[]

Doc from com.sun.jna.Pointer.write.

char array from which to copy

index:int

Doc from com.sun.jna.Pointer.write.

array index from which to start copying

length:int

Doc from com.sun.jna.Pointer.write.

number of elements from buf that must be copied

See Also
Pointer#write(long, char[], int, int)
writeback to summary
public void write(long bOff, int[] buf, int index, int length)

Overrides com.sun.jna.Pointer.write.

Indirect the native pointer to 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.

Parameters
bOff:long

Doc from com.sun.jna.Pointer.write.

byte offset from pointer into which data is copied

buf:int[]

Doc from com.sun.jna.Pointer.write.

int array from which to copy

index:int

Doc from com.sun.jna.Pointer.write.

array index from which to start copying

length:int

Doc from com.sun.jna.Pointer.write.

number of elements from buf that must be copied

See Also
Pointer#write(long, int[], int, int)
writeback to summary
public void write(long bOff, long[] buf, int index, int length)

Overrides com.sun.jna.Pointer.write.

Indirect the native pointer to 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.

Parameters
bOff:long

Doc from com.sun.jna.Pointer.write.

byte offset from pointer into which data is copied

buf:long[]

Doc from com.sun.jna.Pointer.write.

long array from which to copy

index:int

Doc from com.sun.jna.Pointer.write.

array index from which to start copying

length:int

Doc from com.sun.jna.Pointer.write.

number of elements from buf that must be copied

See Also
Pointer#write(long, long[], int, int)
writeback to summary
public void write(long bOff, float[] buf, int index, int length)

Overrides com.sun.jna.Pointer.write.

Indirect the native pointer to 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.

Parameters
bOff:long

Doc from com.sun.jna.Pointer.write.

byte offset from pointer into which data is copied

buf:float[]

Doc from com.sun.jna.Pointer.write.

float array from which to copy

index:int

Doc from com.sun.jna.Pointer.write.

array index from which to start copying

length:int

Doc from com.sun.jna.Pointer.write.

number of elements from buf that must be copied

See Also
Pointer#write(long, float[], int, int)
writeback to summary
public void write(long bOff, double[] buf, int index, int length)

Overrides com.sun.jna.Pointer.write.

Indirect the native pointer to 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.

Parameters
bOff:long

Doc from com.sun.jna.Pointer.write.

byte offset from pointer into which data is copied

buf:double[]

Doc from com.sun.jna.Pointer.write.

double array from which to copy

index:int

Doc from com.sun.jna.Pointer.write.

array index from which to start copying

length:int

Doc from com.sun.jna.Pointer.write.

number of elements from buf that must be copied

See Also
Pointer#write(long, double[], int, int)
com.sun.jna back to summary

private Class Memory.SharedMemory

extends Memory
Class Inheritance

Provide a view into the original memory.

Field Summary

Inherited from com.sun.jna.Memory:
size

Constructor Summary

AccessConstructor and Description
public
SharedMemory(long offset)

Method Summary

Modifier and TypeMethod and Description
protected void
boundsCheck(long off, long sz)

Overrides com.sun.jna.Memory.boundsCheck.

Pass bounds check to parent.
protected void
finalize()

Overrides com.sun.jna.Memory.finalize.

No need to free memory.
public String
toString()

Overrides com.sun.jna.Memory.toString.

Returns a string representation of the object.
Inherited from com.sun.jna.Memory:
alignclearfreegetBytegetByteBuffergetChargetDoublegetFloatgetIntgetLonggetPointergetShortgetSizegetStringisValidmallocreadreadreadreadreadreadreadsetBytesetCharsetDoublesetFloatsetIntsetLongsetPointersetShortsetStringsharesharewritewritewritewritewritewritewrite

Constructor Detail

SharedMemoryback to summary
public SharedMemory(long offset)

Method Detail

boundsCheckback to summary
protected void boundsCheck(long off, long sz)

Overrides com.sun.jna.Memory.boundsCheck.

Pass bounds check to parent.

finalizeback to summary
protected void finalize()

Overrides com.sun.jna.Memory.finalize.

No need to free memory.

toStringback to summary
public String toString()

Overrides com.sun.jna.Memory.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.