|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.jstatcom.engine.CPtr com.jstatcom.engine.CMalloc
public final class CMalloc
A CPtr
to memory obtained from the C heap via a call to
malloc
.
In some cases it might be necessary to use memory obtained from
malloc
. For example, CMalloc
helps accomplish
the following idiom:
void *buf = malloc(BUF_LEN * sizeof(char)); call_some_function(buf); free(buf);
Remember to free
any malloc
space
explicitly. This class could perhaps contain a finalize
method that does the free
, but note that in Java you should
not use finalizers to free resources.
CPtr
Field Summary |
---|
Fields inherited from class com.jstatcom.engine.CPtr |
---|
NULL, SIZE |
Constructor Summary | |
---|---|
CMalloc(int size)
Allocate space in the C heap via a call to C's malloc . |
Method Summary | |
---|---|
void |
copyIn(int bOff,
byte[] buf,
int index,
int length)
Indirect the C pointer to malloc space, a la
CPtr.copyIn . |
void |
copyIn(int bOff,
char[] buf,
int index,
int length)
Indirect the C pointer to malloc space, a la
CPtr.copyIn . |
void |
copyIn(int bOff,
double[] buf,
int index,
int length)
Indirect the C pointer to malloc space, a la
CPtr.copyIn . |
void |
copyIn(int bOff,
float[] buf,
int index,
int length)
Indirect the C pointer to malloc space, a la
CPtr.copyIn . |
void |
copyIn(int bOff,
int[] buf,
int index,
int length)
Indirect the C pointer to malloc space, a la
CPtr.copyIn . |
void |
copyIn(int bOff,
long[] buf,
int index,
int length)
Indirect the C pointer to malloc space, a la
CPtr.copyIn . |
void |
copyIn(int bOff,
short[] buf,
int index,
int length)
Indirect the C pointer to malloc space, a la
CPtr.copyIn . |
void |
copyOut(int bOff,
byte[] buf,
int index,
int length)
Indirect the C pointer to malloc space, a la
CPtr.copyOut . |
void |
copyOut(int bOff,
char[] buf,
int index,
int length)
Indirect the C pointer to malloc space, a la
CPtr.copyOut . |
void |
copyOut(int bOff,
double[] buf,
int index,
int length)
Indirect the C pointer to malloc space, a la
CPtr.copyOut . |
void |
copyOut(int bOff,
float[] buf,
int index,
int length)
Indirect the C pointer to malloc space, a la
CPtr.copyOut . |
void |
copyOut(int bOff,
int[] buf,
int index,
int length)
Indirect the C pointer to malloc space, a la
CPtr.copyOut . |
void |
copyOut(int bOff,
long[] buf,
int index,
int length)
Indirect the C pointer to malloc space, a la
CPtr.copyOut . |
void |
copyOut(int bOff,
short[] buf,
int index,
int length)
Indirect the C pointer to malloc space, a la
CPtr.copyOut . |
void |
free()
De-allocate space obtained via an earlier call to malloc . |
byte |
getByte(int offset)
Indirect the C pointer to malloc space, a la
CPtr.getByte . |
CPtr |
getCPtr(int offset)
Indirect the C pointer to malloc space, a la
CPtr.getCPtr . |
double |
getDouble(int offset)
Indirect the C pointer to malloc space, a la
CPtr.getDouble . |
float |
getFloat(int offset)
Indirect the C pointer to malloc space, a la
CPtr.getFloat . |
int |
getInt(int offset)
Indirect the C pointer to malloc space, a la
CPtr.getInt . |
long |
getLong(int offset)
Indirect the C pointer to malloc space, a la
CPtr.getLong . |
short |
getShort(int offset)
Indirect the C pointer to malloc space, a la
CPtr.getShort . |
java.lang.String |
getString(int offset)
Indirect the C pointer to malloc space, a la
CPtr.getString . |
void |
setByte(int offset,
byte value)
Indirect the C pointer to malloc space, a la
CPtr.setByte . |
void |
setCPtr(int offset,
CPtr value)
Indirect the C pointer to malloc space, a la
CPtr.setCPtr . |
void |
setDouble(int offset,
double value)
Indirect the C pointer to malloc space, a la
CPtr.setDouble . |
void |
setFloat(int offset,
float value)
Indirect the C pointer to malloc space, a la
CPtr.setFloat . |
void |
setInt(int offset,
int value)
Indirect the C pointer to malloc space, a la
CPtr.setInt . |
void |
setLong(int offset,
long value)
Indirect the C pointer to malloc space, a la
CPtr.setLong . |
void |
setShort(int offset,
short value)
Indirect the C pointer to malloc space, a la
CPtr.setShort . |
void |
setString(int offset,
java.lang.String value)
Indirect the C pointer to malloc space, a la
CPtr.setString . |
Methods inherited from class com.jstatcom.engine.CPtr |
---|
equals, hashCode |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CMalloc(int size)
malloc
.
size
- number of bytes of space to allocateMethod Detail |
---|
public void free()
malloc
.
public void copyIn(int bOff, byte[] buf, int index, int length)
malloc
space, a la
CPtr.copyIn
. But this method performs a bounds checks to
ensure that the indirection does not cause memory outside the
malloc
ed space to be accessed.
copyIn
in class CPtr
bOff
- byte offset from pointer into which data is copiedbuf
- byte
array from which to copyindex
- array index from which to start copyinglength
- number of elements from buf
that must be copiedCPtr.copyIn(int,byte[],int,int)
public void copyIn(int bOff, short[] buf, int index, int length)
malloc
space, a la
CPtr.copyIn
. But this method performs a bounds checks to
ensure that the indirection does not cause memory outside the
malloc
ed space to be accessed.
copyIn
in class CPtr
bOff
- byte offset from pointer into which data is copiedbuf
- short
array from which to copyindex
- array index from which to start copyinglength
- number of elements from buf
that must be copiedCPtr.copyIn(int,short[],int,int)
public void copyIn(int bOff, char[] buf, int index, int length)
malloc
space, a la
CPtr.copyIn
. But this method performs a bounds checks to
ensure that the indirection does not cause memory outside the
malloc
ed space to be accessed.
copyIn
in class CPtr
bOff
- byte offset from pointer into which data is copiedbuf
- char
array from which to copyindex
- array index from which to start copyinglength
- number of elements from buf
that must be copiedCPtr.copyIn(int,char[],int,int)
public void copyIn(int bOff, int[] buf, int index, int length)
malloc
space, a la
CPtr.copyIn
. But this method performs a bounds checks to
ensure that the indirection does not cause memory outside the
malloc
ed space to be accessed.
copyIn
in class CPtr
bOff
- byte offset from pointer into which data is copiedbuf
- int
array from which to copyindex
- array index from which to start copyinglength
- number of elements from buf
that must be copiedCPtr.copyIn(int,int[],int,int)
public void copyIn(int bOff, long[] buf, int index, int length)
malloc
space, a la
CPtr.copyIn
. But this method performs a bounds checks to
ensure that the indirection does not cause memory outside the
malloc
ed space to be accessed.
copyIn
in class CPtr
bOff
- byte offset from pointer into which data is copiedbuf
- long
array from which to copyindex
- array index from which to start copyinglength
- number of elements from buf
that must be copiedCPtr.copyIn(int,long[],int,int)
public void copyIn(int bOff, float[] buf, int index, int length)
malloc
space, a la
CPtr.copyIn
. But this method performs a bounds checks to
ensure that the indirection does not cause memory outside the
malloc
ed space to be accessed.
copyIn
in class CPtr
bOff
- byte offset from pointer into which data is copiedbuf
- float
array from which to copyindex
- array index from which to start copyinglength
- number of elements from buf
that must be copiedCPtr.copyIn(int,float[],int,int)
public void copyIn(int bOff, double[] buf, int index, int length)
malloc
space, a la
CPtr.copyIn
. But this method performs a bounds checks to
ensure that the indirection does not cause memory outside the
malloc
ed space to be accessed.
copyIn
in class CPtr
bOff
- byte offset from pointer into which data is copiedbuf
- double
array from which to copyindex
- array index from which to start copyinglength
- number of elements from buf
that must be copiedCPtr.copyIn(int,double[],int,int)
public void copyOut(int bOff, byte[] buf, int index, int length)
malloc
space, a la
CPtr.copyOut
. But this method performs a bounds checks to
ensure that the indirection does not cause memory outside the
malloc
ed space to be accessed.
copyOut
in class CPtr
bOff
- byte offset from pointer into which data is copiedbuf
- byte
array into which data is copiedindex
- array index from which to start copyinglength
- number of elements from C pointer that must be copiedCPtr.copyOut(int,byte[],int,int)
public void copyOut(int bOff, short[] buf, int index, int length)
malloc
space, a la
CPtr.copyOut
. But this method performs a bounds checks to
ensure that the indirection does not cause memory outside the
malloc
ed space to be accessed.
copyOut
in class CPtr
bOff
- byte offset from pointer from which data is copiedbuf
- short
array into which data is copiedindex
- array index to which data is copiedlength
- number of elements from C pointer that must be copiedCPtr.copyOut(int,short[],int,int)
public void copyOut(int bOff, char[] buf, int index, int length)
malloc
space, a la
CPtr.copyOut
. But this method performs a bounds checks to
ensure that the indirection does not cause memory outside the
malloc
ed space to be accessed.
copyOut
in class CPtr
bOff
- byte offset from pointer from which data is copiedbuf
- char
array into which data is copiedindex
- array index to which data is copiedlength
- number of elements from C pointer that must be copiedCPtr.copyOut(int,char[],int,int)
public void copyOut(int bOff, int[] buf, int index, int length)
malloc
space, a la
CPtr.copyOut
. But this method performs a bounds checks to
ensure that the indirection does not cause memory outside the
malloc
ed space to be accessed.
copyOut
in class CPtr
bOff
- byte offset from pointer from which data is copiedbuf
- int
array into which data is copiedindex
- array index to which data is copiedlength
- number of elements from C pointer that must be copiedCPtr.copyOut(int,int[],int,int)
public void copyOut(int bOff, long[] buf, int index, int length)
malloc
space, a la
CPtr.copyOut
. But this method performs a bounds checks to
ensure that the indirection does not cause memory outside the
malloc
ed space to be accessed.
copyOut
in class CPtr
bOff
- byte offset from pointer from which data is copiedbuf
- long
array into which data is copiedindex
- array index to which data is copiedlength
- number of elements from C pointer that must be copiedCPtr.copyOut(int,long[],int,int)
public void copyOut(int bOff, float[] buf, int index, int length)
malloc
space, a la
CPtr.copyOut
. But this method performs a bounds checks to
ensure that the indirection does not cause memory outside the
malloc
ed space to be accessed.
copyOut
in class CPtr
bOff
- byte offset from pointer from which data is copiedbuf
- float
array into which data is copiedindex
- array index to which data is copiedlength
- number of elements from C pointer that must be copiedCPtr.copyOut(int,float[],int,int)
public void copyOut(int bOff, double[] buf, int index, int length)
malloc
space, a la
CPtr.copyOut
. But this method performs a bounds checks to
ensure that the indirection does not cause memory outside the
malloc
ed space to be accessed.
copyOut
in class CPtr
bOff
- byte offset from pointer from which data is copiedbuf
- double
array into which data is copiedindex
- array index to which data is copiedlength
- number of elements from C pointer that must be copiedCPtr.copyOut(int,double[],int,int)
public byte getByte(int offset)
malloc
space, a la
CPtr.getByte
. But this method performs a bounds checks to
ensure that the indirection does not cause memory outside the
malloc
ed space to be accessed.
getByte
in class CPtr
offset
- offset from pointer to perform the indirection
byte
value being pointed toCPtr.getByte(int)
public short getShort(int offset)
malloc
space, a la
CPtr.getShort
. But this method performs a bounds checks to
ensure that the indirection does not cause memory outside the
malloc
ed space to be accessed.
getShort
in class CPtr
offset
- byte offset from pointer to perform the indirection
short
value being pointed toCPtr.getShort(int)
public int getInt(int offset)
malloc
space, a la
CPtr.getInt
. But this method performs a bounds checks to
ensure that the indirection does not cause memory outside the
malloc
ed space to be accessed.
getInt
in class CPtr
offset
- byte offset from pointer to perform the indirection
int
value being pointed toCPtr.getInt(int)
public long getLong(int offset)
malloc
space, a la
CPtr.getLong
. But this method performs a bounds checks to
ensure that the indirection does not cause memory outside the
malloc
ed space to be accessed.
getLong
in class CPtr
offset
- byte offset from pointer to perform the indirection
long
value being pointed toCPtr.getLong(int)
public float getFloat(int offset)
malloc
space, a la
CPtr.getFloat
. But this method performs a bounds checks to
ensure that the indirection does not cause memory outside the
malloc
ed space to be accessed.
getFloat
in class CPtr
offset
- byte offset from pointer to perform the indirection
float
value being pointed toCPtr.getFloat(int)
public double getDouble(int offset)
malloc
space, a la
CPtr.getDouble
. But this method performs a bounds checks
to ensure that the indirection does not cause memory outside the
malloc
ed space to be accessed.
getDouble
in class CPtr
offset
- byte offset from pointer to perform the indirection
double
value being pointed toCPtr.getDouble(int)
public CPtr getCPtr(int offset)
malloc
space, a la
CPtr.getCPtr
. But this method performs a bounds checks to
ensure that the indirection does not cause memory outside the
malloc
ed space to be accessed.
getCPtr
in class CPtr
offset
- byte offset from pointer to perform the indirection
pointer
value being pointed toCPtr.getCPtr(int)
public java.lang.String getString(int offset)
malloc
space, a la
CPtr.getString
. But this method performs a bounds checks
to ensure that the indirection does not cause memory outside the
malloc
ed space to be accessed.
getString
in class CPtr
offset
- byte offset from pointer to obtain the C string
String
value being pointed toCPtr.getString(int)
public void setByte(int offset, byte value)
malloc
space, a la
CPtr.setByte
. But this method performs a bounds checks to
ensure that the indirection does not cause memory outside the
malloc
ed space to be accessed.
setByte
in class CPtr
offset
- byte offset from pointer at which value
must be
setvalue
- byte
value to setCPtr.setByte(int, byte)
public void setShort(int offset, short value)
malloc
space, a la
CPtr.setShort
. But this method performs a bounds checks to
ensure that the indirection does not cause memory outside the
malloc
ed space to be accessed.
setShort
in class CPtr
offset
- byte offset from pointer at which value
must be
setvalue
- short
value to setCPtr.setShort(int, short)
public void setInt(int offset, int value)
malloc
space, a la
CPtr.setInt
. But this method performs a bounds checks to
ensure that the indirection does not cause memory outside the
malloc
ed space to be accessed.
setInt
in class CPtr
offset
- byte offset from pointer at which value
must be
setvalue
- int
value to setCPtr.setInt(int, int)
public void setLong(int offset, long value)
malloc
space, a la
CPtr.setLong
. But this method performs a bounds checks to
ensure that the indirection does not cause memory outside the
malloc
ed space to be accessed.
setLong
in class CPtr
offset
- byte offset from pointer at which value
must be
setvalue
- long
value to setCPtr.setLong(int, long)
public void setFloat(int offset, float value)
malloc
space, a la
CPtr.setFloat
. But this method performs a bounds checks to
ensure that the indirection does not cause memory outside the
malloc
ed space to be accessed.
setFloat
in class CPtr
offset
- byte offset from pointer at which value
must be
setvalue
- float
value to setCPtr.setFloat(int, float)
public void setDouble(int offset, double value)
malloc
space, a la
CPtr.setDouble
. But this method performs a bounds checks
to ensure that the indirection does not cause memory outside the
malloc
ed space to be accessed.
setDouble
in class CPtr
offset
- byte offset from pointer at which value
must be
setvalue
- double
value to setCPtr.setDouble(int, double)
public void setCPtr(int offset, CPtr value)
malloc
space, a la
CPtr.setCPtr
. But this method performs a bounds checks to
ensure that the indirection does not cause memory outside the
malloc
ed space to be accessed.
setCPtr
in class CPtr
offset
- byte offset from pointer at which value
must be
setvalue
- CPtr
value to setCPtr.setCPtr(int, com.jstatcom.engine.CPtr)
public void setString(int offset, java.lang.String value)
malloc
space, a la
CPtr.setString
. But this method performs a bounds checks
to ensure that the indirection does not cause memory outside the
malloc
ed space to be accessed.
setString
in class CPtr
offset
- byte offset from pointer at which characters in
value
must be setvalue
- String
value to setCPtr.setString(int, java.lang.String)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |