|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectvs.Cmem
Provides a mechanism to allocate memory using the C malloc routine. And a way to copy data from and to java arrays and built-in types to the allocated memory. Used when the address of a memory block is needed, for instance when building item lists, and when calling asynchronous routines, when the needs of the java garbage colector and the async routines mean that java allocated memory cannot be used.
The methods for accessing storage check all ranges and do not allow altering storage outside the allocated region. This protects against buffer overrun errors.
| Constructor Summary | |
Cmem(int size)
constructor, size in bytes provided. |
|
| Method Summary | |
int |
bytecopyin(byte b)
copy a byte into the C memory |
byte |
bytecopyout()
get the first byte in the C memory |
int |
copyin(byte[] b)
copy data to the C memory from a byte array |
int |
copyin(int[] b)
copy data to the C memory from an int array |
int |
copyin(long[] b)
copy data to the C memory from a long array |
int |
copyin(short[] b)
copy data to the C memory from a short array |
int |
copyin(java.lang.String s)
Copy data to virtual memory region from String object. |
int |
copyin(VmsStruct s)
Copy data to virtual memory region from VmsStruct object. |
java.lang.String |
copyout()
Copy contents of memory to a String object. |
int |
copyout(byte[] b)
copy data from the C memory to a byte array |
java.lang.String |
copyout(int len)
Copy portion of memory contents to a String object. |
int |
copyout(int[] b)
copy data from the C memory to an int array |
int |
copyout(long[] b)
copy data from the C memory to a long array |
int |
copyout(short[] b)
copy data from the C memory to an int array |
int |
copyout(VmsStruct s)
Copy contents of memory to a VmsStruct object. |
void |
finalize()
|
void |
free()
deallocate the C memory. |
int |
getPeer()
return a pointer to the C memory |
int |
intcopyin(int i)
copy an int into the C memory |
int |
intcopyout()
get the first int in the C memory |
int |
length()
Return the size (in bytes) of the allocated region. |
int |
longcopyin(long b)
copy a long into the C memory |
long |
longcopyout()
get the first long in the C memory |
int |
shortcopyin(short s)
copy a short into the C memory |
short |
shortcopyout()
get the first short in the C memory |
| Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public Cmem(int size)
| Method Detail |
public void free()
public void finalize()
public int getPeer()
public int length()
public int copyin(byte[] b)
public int copyin(VmsStruct s)
VmsStruct object.
This method copies the underlying byte[] array into
the memory region allocated by this Cmem object.
s - VmsStruct object to copy into memory.
public int copyin(java.lang.String s)
String object.
This method accepts a String object that is converted
to a byte[] array. The array is then written to the
alloccated memory region.
s - String object to copy to memory.
public int copyout(byte[] b)
public int copyout(VmsStruct s)
VmsStruct object.
The underlying byte[] array of the VmsStruct
object is updated with the contents of the memory region.
s - VmsStruct object to receive a copy
of the memory region contents.
bytes copied from the
memory region.public java.lang.String copyout()
String object.
A new String object is constructed from the contents
of the memory region.
String object containg a copy of the
memory region contents.public java.lang.String copyout(int len)
String object.
A new String object is constructed from the contents
of the memory region. No more than len bytes are
stored in the String object.
len - maximum number of bytes to include
in the String object.
String object containg a copy of the
memory region contents.public int copyin(short[] b)
public int copyout(short[] b)
public int copyin(int[] b)
public int copyout(int[] b)
public int copyin(long[] b)
public int copyout(long[] b)
public long longcopyout()
public int intcopyout()
public short shortcopyout()
public byte bytecopyout()
public int longcopyin(long b)
public int intcopyin(int i)
public int shortcopyin(short s)
public int bytecopyin(byte b)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||