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);
Pointer
| Modifier and Type | Class and Description |
|---|---|
| private static class | |
| private class | Memory.SharedMemory
Provide a view into the original memory. |
| Modifier and Type | Field and Description |
|---|---|
| private static final Map | allocatedMemory
Keep track of all allocated memory so we can dispose of it before unloading. |
| private static final WeakMemoryHolder | |
| private final Cleaner. | |
| protected long |
| Access | Constructor 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 |
| protected |
| Modifier and Type | Method and Description |
|---|---|
| public Memory | 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 | |
| public void | |
| protected void | |
| public static void | |
| public String | |
| protected static void | |
| public byte | getByte(long
offset from pointer to perform the indirection offset)Overrides com. malloc space, a la
Pointer.getByte.
|
| public ByteBuffer | Returns: a direct ByteBuffer that accesses the memory being pointed to,byte offset from pointer to start the buffer offset, long Length of ByteBuffer length)Overrides com. |
| public char | getChar(long
offset from pointer to perform the indirection offset)Overrides com. malloc space, a la
Pointer.getByte.
|
| public double | getDouble(long
byte offset from pointer to perform the indirection offset)Overrides com. malloc space, a la
Pointer.getDouble.
|
| public float | getFloat(long
byte offset from pointer to perform the indirection offset)Overrides com. malloc space, a la
Pointer.getFloat.
|
| public int | getInt(long
byte offset from pointer to perform the indirection offset)Overrides com. malloc space, a la
Pointer.getInt.
|
| public long | getLong(long
byte offset from pointer to perform the indirection offset)Overrides com. malloc space, a la
Pointer.getLong.
|
| public Pointer | getPointer(long
byte offset from pointer to perform the indirection offset)Overrides com. malloc space, a la
Pointer.getPointer.
|
| public short | getShort(long
byte offset from pointer to perform the indirection offset)Overrides com. malloc space, a la
Pointer.getShort.
|
| public String | getString(long
byte offset from pointer to obtain the native string offset, String the desired encoding encoding)Overrides com. |
| public String | getWideString(long offset)
Overrides com. const wchar_t *) string from memory.
|
| protected static long | |
| public static void | |
| public void | read(long
byte offset from pointer from which data is copied bOff, byte[] byte array into which data is copiedarray index to which data is copied index, int number of elements from native pointer that must be copied length)Overrides com. 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 copiedarray index to which data is copied index, int number of elements from native pointer that must be copied length)Overrides com. 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 copiedarray index to which data is copied index, int number of elements from native pointer that must be copied length)Overrides com. 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 copiedarray index to which data is copied index, int number of elements from native pointer that must be copied length)Overrides com. 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 copiedarray index to which data is copied index, int number of elements from native pointer that must be copied length)Overrides com. 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 copiedarray index to which data is copied index, int number of elements from native pointer that must be copied length)Overrides com. 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 copiedarray index to which data is copied index, int number of elements from native pointer that must be copied length)Overrides com. malloc space, a la
Pointer.read.
|
| public void | read(long
byte offset from pointer from which data is copied bOff, Pointer[] Pointer array into which data is copiedarray index to which data is copied index, int number of elements from native pointer that must be copied length)Overrides com. malloc space, a la
Pointer.read.
|
| public void | setByte(long
byte offset from pointer at which offset, byte value must
be setbyte value to setOverrides com. malloc space, a la
Pointer.setByte.
|
| public void | setChar(long
byte offset from pointer at which offset, char value
must be setchar value to setOverrides com. malloc space, a la
Pointer.setChar.
|
| public void | setDouble(long
byte offset from pointer at which offset, double value
must be setdouble value to setOverrides com. malloc space, a la
Pointer.setDouble.
|
| public void | setFloat(long
byte offset from pointer at which offset, float value
must be setfloat value to setOverrides com. malloc space, a la
Pointer.setFloat.
|
| public void | setInt(long
byte offset from pointer at which offset, int value must
be setint value to setOverrides com. malloc space, a la
Pointer.setInt.
|
| public void | setLong(long
byte offset from pointer at which offset, long value
must be setlong value to setOverrides com. malloc space, a la
Pointer.setLong.
|
| public void | setPointer(long
byte offset from pointer at which offset, Pointer value
must be setPointer holding the actual pointer value to
set, which may be null to indicate a NULL
pointer.Overrides com. malloc space, a la
Pointer.setPointer.
|
| public void | setShort(long
byte offset from pointer at which offset, short value must
be setshort value to setOverrides com. malloc space, a la
Pointer.setShort.
|
| public void | setString(long
byte offset from pointer at which characters in
offset, String value must be setjava.lang.String value to setdesired encoding encoding)Overrides com. value to the location being pointed to, using
the requested encoding.
|
| public void | setWideString(long
byte offset from pointer at which characters in
offset, String value must be setjava.lang.String value to setOverrides com. value to the location being pointed to as a
wide string (wchar_t*).
|
| public Pointer | share(long offset)
Overrides com. |
| public Pointer | share(long offset, long sz)
Overrides com. |
| private Pointer | Returns: target if target does not point into the region covered
by this memory object, a newly SharedMemory object, if the pointer
points to memory backed by this Memory object.Pointer to check target)Check whether the supplied Pointer object points into the memory region backed by this memory object. |
| public long | |
| public String | |
| public boolean | |
| public void | write(long
byte offset from pointer into which data is copied bOff, byte[] byte array from which to copyarray index from which to start copying index, int number of elements from length)buf that must be
copiedOverrides com. 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 copyarray index from which to start copying index, int number of elements from length)buf that must be
copiedOverrides com. 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 copyarray index from which to start copying index, int number of elements from length)buf that must be
copiedOverrides com. 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 copyarray index from which to start copying index, int number of elements from length)buf that must be
copiedOverrides com. 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 copyarray index from which to start copying index, int number of elements from length)buf that must be
copiedOverrides com. 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 copyarray index from which to start copying index, int number of elements from length)buf that must be
copiedOverrides com. 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 copyarray index from which to start copying index, int number of elements from length)buf that must be
copiedOverrides com. malloc space, a la
Pointer.write.
|
| public void | write(long
byte offset from pointer into which data is copied bOff, Pointer[] Pointer array from which to copyarray index from which to start copying index, int number of elements from length)buf that must be
copiedOverrides com. malloc space, a la
Pointer.write.
|