|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--CPointer | +--CMalloc
A CPointer
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.
CPointer
Fields inherited from class CPointer |
peer,
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
CPointer.copyIn . |
void |
copyIn(int bOff,
char[] buf,
int index,
int length)
Indirect the C pointer to malloc space, a la
CPointer.copyIn . |
void |
copyIn(int bOff,
double[] buf,
int index,
int length)
Indirect the C pointer to malloc space, a la
CPointer.copyIn . |
void |
copyIn(int bOff,
float[] buf,
int index,
int length)
Indirect the C pointer to malloc space, a la
CPointer.copyIn . |
void |
copyIn(int bOff,
int[] buf,
int index,
int length)
Indirect the C pointer to malloc space, a la
CPointer.copyIn . |
void |
copyIn(int bOff,
long[] buf,
int index,
int length)
Indirect the C pointer to malloc space, a la
CPointer.copyIn . |
void |
copyIn(int bOff,
short[] buf,
int index,
int length)
Indirect the C pointer to malloc space, a la
CPointer.copyIn . |
void |
copyOut(int bOff,
byte[] buf,
int index,
int length)
Indirect the C pointer to malloc space, a la
CPointer.copyOut . |
void |
copyOut(int bOff,
char[] buf,
int index,
int length)
Indirect the C pointer to malloc space, a la
CPointer.copyOut . |
void |
copyOut(int bOff,
double[] buf,
int index,
int length)
Indirect the C pointer to malloc space, a la
CPointer.copyOut . |
void |
copyOut(int bOff,
float[] buf,
int index,
int length)
Indirect the C pointer to malloc space, a la
CPointer.copyOut . |
void |
copyOut(int bOff,
int[] buf,
int index,
int length)
Indirect the C pointer to malloc space, a la
CPointer.copyOut . |
void |
copyOut(int bOff,
long[] buf,
int index,
int length)
Indirect the C pointer to malloc space, a la
CPointer.copyOut . |
void |
copyOut(int bOff,
short[] buf,
int index,
int length)
Indirect the C pointer to malloc space, a la
CPointer.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
CPointer.getByte . |
CPointer |
getCPointer(int offset)
Indirect the C pointer to malloc space, a la
CPointer.getCPointer . |
double |
getDouble(int offset)
Indirect the C pointer to malloc space, a la
CPointer.getDouble . |
float |
getFloat(int offset)
Indirect the C pointer to malloc space, a la
CPointer.getFloat . |
int |
getInt(int offset)
Indirect the C pointer to malloc space, a la
CPointer.getInt . |
long |
getLong(int offset)
Indirect the C pointer to malloc space, a la
CPointer.getLong . |
short |
getShort(int offset)
Indirect the C pointer to malloc space, a la
CPointer.getShort . |
java.lang.String |
getString(int offset)
Indirect the C pointer to malloc space, a la
CPointer.getString . |
void |
setByte(int offset,
byte value)
Indirect the C pointer to malloc space, a la
CPointer.setByte . |
void |
setCPointer(int offset,
CPointer value)
Indirect the C pointer to malloc space, a la
CPointer.setCPointer . |
void |
setDouble(int offset,
double value)
Indirect the C pointer to malloc space, a la
CPointer.setDouble . |
void |
setFloat(int offset,
float value)
Indirect the C pointer to malloc space, a la
CPointer.setFloat . |
void |
setInt(int offset,
int value)
Indirect the C pointer to malloc space, a la
CPointer.setInt . |
void |
setLong(int offset,
long value)
Indirect the C pointer to malloc space, a la
CPointer.setLong . |
void |
setShort(int offset,
short value)
Indirect the C pointer to malloc space, a la
CPointer.setShort . |
void |
setString(int offset,
java.lang.String value)
Indirect the C pointer to malloc space, a la
CPointer.setString . |
Methods inherited from class CPointer |
equals,
hashCode |
Methods inherited from class java.lang.Object |
clone,
finalize,
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
CPointer.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.CPointer.copyIn(int,byte[],int,int)
public void copyIn(int bOff, short[] buf, int index, int length)
malloc
space, a la
CPointer.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.CPointer.copyIn(int,short[],int,int)
public void copyIn(int bOff, char[] buf, int index, int length)
malloc
space, a la
CPointer.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.CPointer.copyIn(int,char[],int,int)
public void copyIn(int bOff, int[] buf, int index, int length)
malloc
space, a la
CPointer.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.CPointer.copyIn(int,int[],int,int)
public void copyIn(int bOff, long[] buf, int index, int length)
malloc
space, a la
CPointer.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.CPointer.copyIn(int,long[],int,int)
public void copyIn(int bOff, float[] buf, int index, int length)
malloc
space, a la
CPointer.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.CPointer.copyIn(int,float[],int,int)
public void copyIn(int bOff, double[] buf, int index, int length)
malloc
space, a la
CPointer.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.CPointer.copyIn(int,double[],int,int)
public void copyOut(int bOff, byte[] buf, int index, int length)
malloc
space, a la
CPointer.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.CPointer.copyOut(int,byte[],int,int)
public void copyOut(int bOff, short[] buf, int index, int length)
malloc
space, a la
CPointer.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.CPointer.copyOut(int,short[],int,int)
public void copyOut(int bOff, char[] buf, int index, int length)
malloc
space, a la
CPointer.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.CPointer.copyOut(int,char[],int,int)
public void copyOut(int bOff, int[] buf, int index, int length)
malloc
space, a la
CPointer.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.CPointer.copyOut(int,int[],int,int)
public void copyOut(int bOff, long[] buf, int index, int length)
malloc
space, a la
CPointer.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.CPointer.copyOut(int,long[],int,int)
public void copyOut(int bOff, float[] buf, int index, int length)
malloc
space, a la
CPointer.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.CPointer.copyOut(int,float[],int,int)
public void copyOut(int bOff, double[] buf, int index, int length)
malloc
space, a la
CPointer.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.CPointer.copyOut(int,double[],int,int)
public byte getByte(int offset)
malloc
space, a la
CPointer.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.CPointer.getByte(int)
public short getShort(int offset)
malloc
space, a la
CPointer.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.CPointer.getShort(int)
public int getInt(int offset)
malloc
space, a la
CPointer.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.CPointer.getInt(int)
public long getLong(int offset)
malloc
space, a la
CPointer.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.CPointer.getLong(int)
public float getFloat(int offset)
malloc
space, a la
CPointer.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.CPointer.getFloat(int)
public double getDouble(int offset)
malloc
space, a la
CPointer.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.CPointer.getDouble(int)
public CPointer getCPointer(int offset)
malloc
space, a la
CPointer.getCPointer
. But this method performs a bounds
checks to
ensure that the indirection does not cause memory outside the
malloc
ed space to be accessed.CPointer.getCPointer(int)
public java.lang.String getString(int offset)
malloc
space, a la
CPointer.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.CPointer.getString(int)
public void setByte(int offset, byte value)
malloc
space, a la
CPointer.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.CPointer.setByte(int, byte)
public void setShort(int offset, short value)
malloc
space, a la
CPointer.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.CPointer.setShort(int, short)
public void setInt(int offset, int value)
malloc
space, a la
CPointer.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.CPointer.setInt(int, int)
public void setLong(int offset, long value)
malloc
space, a la
CPointer.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.CPointer.setLong(int, long)
public void setFloat(int offset, float value)
malloc
space, a la
CPointer.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.CPointer.setFloat(int, float)
public void setDouble(int offset, double value)
malloc
space, a la
CPointer.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.CPointer.setDouble(int, double)
public void setCPointer(int offset, CPointer value)
malloc
space, a la
CPointer.setCPointer
. But this method performs a bounds
checks to
ensure that the indirection does not cause memory outside the
malloc
ed space to be accessed.CPointer.setCPointer(int, CPointer)
public void setString(int offset, java.lang.String value)
malloc
space, a la
CPointer.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.CPointer.setString(int, String)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |