com.jstatcom.engine
Class CMalloc
- java.lang.Object
-
- com.jstatcom.engine.CPtr
-
- com.jstatcom.engine.CMalloc
-
public final class CMalloc extends CPtr
ACPtrto memory obtained from the C heap via a call tomalloc.In some cases it might be necessary to use memory obtained from
malloc. For example,CMallochelps accomplish the following idiom:void *buf = malloc(BUF_LEN * sizeof(char)); call_some_function(buf); free(buf);Remember to
freeanymallocspace explicitly. This class could perhaps contain afinalizemethod that does thefree, but note that in Java you should not use finalizers to free resources.- See Also:
CPtr
-
-
Constructor Summary
Constructors Constructor and Description CMalloc(int size)Allocate space in the C heap via a call to C'smalloc.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidcopyIn(int bOff, byte[] buf, int index, int length)Indirect the C pointer tomallocspace, a laCPtr.copyIn.voidcopyIn(int bOff, char[] buf, int index, int length)Indirect the C pointer tomallocspace, a laCPtr.copyIn.voidcopyIn(int bOff, double[] buf, int index, int length)Indirect the C pointer tomallocspace, a laCPtr.copyIn.voidcopyIn(int bOff, float[] buf, int index, int length)Indirect the C pointer tomallocspace, a laCPtr.copyIn.voidcopyIn(int bOff, int[] buf, int index, int length)Indirect the C pointer tomallocspace, a laCPtr.copyIn.voidcopyIn(int bOff, long[] buf, int index, int length)Indirect the C pointer tomallocspace, a laCPtr.copyIn.voidcopyIn(int bOff, short[] buf, int index, int length)Indirect the C pointer tomallocspace, a laCPtr.copyIn.voidcopyOut(int bOff, byte[] buf, int index, int length)Indirect the C pointer tomallocspace, a laCPtr.copyOut.voidcopyOut(int bOff, char[] buf, int index, int length)Indirect the C pointer tomallocspace, a laCPtr.copyOut.voidcopyOut(int bOff, double[] buf, int index, int length)Indirect the C pointer tomallocspace, a laCPtr.copyOut.voidcopyOut(int bOff, float[] buf, int index, int length)Indirect the C pointer tomallocspace, a laCPtr.copyOut.voidcopyOut(int bOff, int[] buf, int index, int length)Indirect the C pointer tomallocspace, a laCPtr.copyOut.voidcopyOut(int bOff, long[] buf, int index, int length)Indirect the C pointer tomallocspace, a laCPtr.copyOut.voidcopyOut(int bOff, short[] buf, int index, int length)Indirect the C pointer tomallocspace, a laCPtr.copyOut.voidfree()De-allocate space obtained via an earlier call tomalloc.bytegetByte(int offset)Indirect the C pointer tomallocspace, a laCPtr.getByte.CPtrgetCPtr(int offset)Indirect the C pointer tomallocspace, a laCPtr.getCPtr.doublegetDouble(int offset)Indirect the C pointer tomallocspace, a laCPtr.getDouble.floatgetFloat(int offset)Indirect the C pointer tomallocspace, a laCPtr.getFloat.intgetInt(int offset)Indirect the C pointer tomallocspace, a laCPtr.getInt.longgetLong(int offset)Indirect the C pointer tomallocspace, a laCPtr.getLong.shortgetShort(int offset)Indirect the C pointer tomallocspace, a laCPtr.getShort.java.lang.StringgetString(int offset)Indirect the C pointer tomallocspace, a laCPtr.getString.voidsetByte(int offset, byte value)Indirect the C pointer tomallocspace, a laCPtr.setByte.voidsetCPtr(int offset, CPtr value)Indirect the C pointer tomallocspace, a laCPtr.setCPtr.voidsetDouble(int offset, double value)Indirect the C pointer tomallocspace, a laCPtr.setDouble.voidsetFloat(int offset, float value)Indirect the C pointer tomallocspace, a laCPtr.setFloat.voidsetInt(int offset, int value)Indirect the C pointer tomallocspace, a laCPtr.setInt.voidsetLong(int offset, long value)Indirect the C pointer tomallocspace, a laCPtr.setLong.voidsetShort(int offset, short value)Indirect the C pointer tomallocspace, a laCPtr.setShort.voidsetString(int offset, java.lang.String value)Indirect the C pointer tomallocspace, a laCPtr.setString.
-
-
-
Constructor Detail
-
CMalloc
public CMalloc(int size)
Allocate space in the C heap via a call to C'smalloc.- Parameters:
size- number of bytes of space to allocate
-
-
Method Detail
-
free
public void free()
De-allocate space obtained via an earlier call tomalloc.
-
copyIn
public void copyIn(int bOff, byte[] buf, int index, int length)Indirect the C pointer tomallocspace, a laCPtr.copyIn. But this method performs a bounds checks to ensure that the indirection does not cause memory outside themalloced space to be accessed.- Overrides:
copyInin classCPtr- Parameters:
bOff- byte offset from pointer into which data is copiedbuf-bytearray from which to copyindex- array index from which to start copyinglength- number of elements frombufthat must be copied- See Also:
CPtr.copyIn(int,byte[],int,int)
-
copyIn
public void copyIn(int bOff, short[] buf, int index, int length)Indirect the C pointer tomallocspace, a laCPtr.copyIn. But this method performs a bounds checks to ensure that the indirection does not cause memory outside themalloced space to be accessed.- Overrides:
copyInin classCPtr- Parameters:
bOff- byte offset from pointer into which data is copiedbuf-shortarray from which to copyindex- array index from which to start copyinglength- number of elements frombufthat must be copied- See Also:
CPtr.copyIn(int,short[],int,int)
-
copyIn
public void copyIn(int bOff, char[] buf, int index, int length)Indirect the C pointer tomallocspace, a laCPtr.copyIn. But this method performs a bounds checks to ensure that the indirection does not cause memory outside themalloced space to be accessed.- Overrides:
copyInin classCPtr- Parameters:
bOff- byte offset from pointer into which data is copiedbuf-chararray from which to copyindex- array index from which to start copyinglength- number of elements frombufthat must be copied- See Also:
CPtr.copyIn(int,char[],int,int)
-
copyIn
public void copyIn(int bOff, int[] buf, int index, int length)Indirect the C pointer tomallocspace, a laCPtr.copyIn. But this method performs a bounds checks to ensure that the indirection does not cause memory outside themalloced space to be accessed.- Overrides:
copyInin classCPtr- Parameters:
bOff- byte offset from pointer into which data is copiedbuf-intarray from which to copyindex- array index from which to start copyinglength- number of elements frombufthat must be copied- See Also:
CPtr.copyIn(int,int[],int,int)
-
copyIn
public void copyIn(int bOff, long[] buf, int index, int length)Indirect the C pointer tomallocspace, a laCPtr.copyIn. But this method performs a bounds checks to ensure that the indirection does not cause memory outside themalloced space to be accessed.- Overrides:
copyInin classCPtr- Parameters:
bOff- byte offset from pointer into which data is copiedbuf-longarray from which to copyindex- array index from which to start copyinglength- number of elements frombufthat must be copied- See Also:
CPtr.copyIn(int,long[],int,int)
-
copyIn
public void copyIn(int bOff, float[] buf, int index, int length)Indirect the C pointer tomallocspace, a laCPtr.copyIn. But this method performs a bounds checks to ensure that the indirection does not cause memory outside themalloced space to be accessed.- Overrides:
copyInin classCPtr- Parameters:
bOff- byte offset from pointer into which data is copiedbuf-floatarray from which to copyindex- array index from which to start copyinglength- number of elements frombufthat must be copied- See Also:
CPtr.copyIn(int,float[],int,int)
-
copyIn
public void copyIn(int bOff, double[] buf, int index, int length)Indirect the C pointer tomallocspace, a laCPtr.copyIn. But this method performs a bounds checks to ensure that the indirection does not cause memory outside themalloced space to be accessed.- Overrides:
copyInin classCPtr- Parameters:
bOff- byte offset from pointer into which data is copiedbuf-doublearray from which to copyindex- array index from which to start copyinglength- number of elements frombufthat must be copied- See Also:
CPtr.copyIn(int,double[],int,int)
-
copyOut
public void copyOut(int bOff, byte[] buf, int index, int length)Indirect the C pointer tomallocspace, a laCPtr.copyOut. But this method performs a bounds checks to ensure that the indirection does not cause memory outside themalloced space to be accessed.- Overrides:
copyOutin classCPtr- Parameters:
bOff- byte offset from pointer into which data is copiedbuf-bytearray into which data is copiedindex- array index from which to start copyinglength- number of elements from C pointer that must be copied- See Also:
CPtr.copyOut(int,byte[],int,int)
-
copyOut
public void copyOut(int bOff, short[] buf, int index, int length)Indirect the C pointer tomallocspace, a laCPtr.copyOut. But this method performs a bounds checks to ensure that the indirection does not cause memory outside themalloced space to be accessed.- Overrides:
copyOutin classCPtr- Parameters:
bOff- byte offset from pointer from which data is copiedbuf-shortarray into which data is copiedindex- array index to which data is copiedlength- number of elements from C pointer that must be copied- See Also:
CPtr.copyOut(int,short[],int,int)
-
copyOut
public void copyOut(int bOff, char[] buf, int index, int length)Indirect the C pointer tomallocspace, a laCPtr.copyOut. But this method performs a bounds checks to ensure that the indirection does not cause memory outside themalloced space to be accessed.- Overrides:
copyOutin classCPtr- Parameters:
bOff- byte offset from pointer from which data is copiedbuf-chararray into which data is copiedindex- array index to which data is copiedlength- number of elements from C pointer that must be copied- See Also:
CPtr.copyOut(int,char[],int,int)
-
copyOut
public void copyOut(int bOff, int[] buf, int index, int length)Indirect the C pointer tomallocspace, a laCPtr.copyOut. But this method performs a bounds checks to ensure that the indirection does not cause memory outside themalloced space to be accessed.- Overrides:
copyOutin classCPtr- Parameters:
bOff- byte offset from pointer from which data is copiedbuf-intarray into which data is copiedindex- array index to which data is copiedlength- number of elements from C pointer that must be copied- See Also:
CPtr.copyOut(int,int[],int,int)
-
copyOut
public void copyOut(int bOff, long[] buf, int index, int length)Indirect the C pointer tomallocspace, a laCPtr.copyOut. But this method performs a bounds checks to ensure that the indirection does not cause memory outside themalloced space to be accessed.- Overrides:
copyOutin classCPtr- Parameters:
bOff- byte offset from pointer from which data is copiedbuf-longarray into which data is copiedindex- array index to which data is copiedlength- number of elements from C pointer that must be copied- See Also:
CPtr.copyOut(int,long[],int,int)
-
copyOut
public void copyOut(int bOff, float[] buf, int index, int length)Indirect the C pointer tomallocspace, a laCPtr.copyOut. But this method performs a bounds checks to ensure that the indirection does not cause memory outside themalloced space to be accessed.- Overrides:
copyOutin classCPtr- Parameters:
bOff- byte offset from pointer from which data is copiedbuf-floatarray into which data is copiedindex- array index to which data is copiedlength- number of elements from C pointer that must be copied- See Also:
CPtr.copyOut(int,float[],int,int)
-
copyOut
public void copyOut(int bOff, double[] buf, int index, int length)Indirect the C pointer tomallocspace, a laCPtr.copyOut. But this method performs a bounds checks to ensure that the indirection does not cause memory outside themalloced space to be accessed.- Overrides:
copyOutin classCPtr- Parameters:
bOff- byte offset from pointer from which data is copiedbuf-doublearray into which data is copiedindex- array index to which data is copiedlength- number of elements from C pointer that must be copied- See Also:
CPtr.copyOut(int,double[],int,int)
-
getByte
public byte getByte(int offset)
Indirect the C pointer tomallocspace, a laCPtr.getByte. But this method performs a bounds checks to ensure that the indirection does not cause memory outside themalloced space to be accessed.- Overrides:
getBytein classCPtr- Parameters:
offset- offset from pointer to perform the indirection- Returns:
- the
bytevalue being pointed to - See Also:
CPtr.getByte(int)
-
getShort
public short getShort(int offset)
Indirect the C pointer tomallocspace, a laCPtr.getShort. But this method performs a bounds checks to ensure that the indirection does not cause memory outside themalloced space to be accessed.- Overrides:
getShortin classCPtr- Parameters:
offset- byte offset from pointer to perform the indirection- Returns:
- the
shortvalue being pointed to - See Also:
CPtr.getShort(int)
-
getInt
public int getInt(int offset)
Indirect the C pointer tomallocspace, a laCPtr.getInt. But this method performs a bounds checks to ensure that the indirection does not cause memory outside themalloced space to be accessed.- Overrides:
getIntin classCPtr- Parameters:
offset- byte offset from pointer to perform the indirection- Returns:
- the
intvalue being pointed to - See Also:
CPtr.getInt(int)
-
getLong
public long getLong(int offset)
Indirect the C pointer tomallocspace, a laCPtr.getLong. But this method performs a bounds checks to ensure that the indirection does not cause memory outside themalloced space to be accessed.- Overrides:
getLongin classCPtr- Parameters:
offset- byte offset from pointer to perform the indirection- Returns:
- the
longvalue being pointed to - See Also:
CPtr.getLong(int)
-
getFloat
public float getFloat(int offset)
Indirect the C pointer tomallocspace, a laCPtr.getFloat. But this method performs a bounds checks to ensure that the indirection does not cause memory outside themalloced space to be accessed.- Overrides:
getFloatin classCPtr- Parameters:
offset- byte offset from pointer to perform the indirection- Returns:
- the
floatvalue being pointed to - See Also:
CPtr.getFloat(int)
-
getDouble
public double getDouble(int offset)
Indirect the C pointer tomallocspace, a laCPtr.getDouble. But this method performs a bounds checks to ensure that the indirection does not cause memory outside themalloced space to be accessed.- Overrides:
getDoublein classCPtr- Parameters:
offset- byte offset from pointer to perform the indirection- Returns:
- the
doublevalue being pointed to - See Also:
CPtr.getDouble(int)
-
getCPtr
public CPtr getCPtr(int offset)
Indirect the C pointer tomallocspace, a laCPtr.getCPtr. But this method performs a bounds checks to ensure that the indirection does not cause memory outside themalloced space to be accessed.- Overrides:
getCPtrin classCPtr- Parameters:
offset- byte offset from pointer to perform the indirection- Returns:
- the
pointervalue being pointed to - See Also:
CPtr.getCPtr(int)
-
getString
public java.lang.String getString(int offset)
Indirect the C pointer tomallocspace, a laCPtr.getString. But this method performs a bounds checks to ensure that the indirection does not cause memory outside themalloced space to be accessed.- Overrides:
getStringin classCPtr- Parameters:
offset- byte offset from pointer to obtain the C string- Returns:
- the
Stringvalue being pointed to - See Also:
CPtr.getString(int)
-
setByte
public void setByte(int offset, byte value)Indirect the C pointer tomallocspace, a laCPtr.setByte. But this method performs a bounds checks to ensure that the indirection does not cause memory outside themalloced space to be accessed.- Overrides:
setBytein classCPtr- Parameters:
offset- byte offset from pointer at whichvaluemust be setvalue-bytevalue to set- See Also:
CPtr.setByte(int, byte)
-
setShort
public void setShort(int offset, short value)Indirect the C pointer tomallocspace, a laCPtr.setShort. But this method performs a bounds checks to ensure that the indirection does not cause memory outside themalloced space to be accessed.- Overrides:
setShortin classCPtr- Parameters:
offset- byte offset from pointer at whichvaluemust be setvalue-shortvalue to set- See Also:
CPtr.setShort(int, short)
-
setInt
public void setInt(int offset, int value)Indirect the C pointer tomallocspace, a laCPtr.setInt. But this method performs a bounds checks to ensure that the indirection does not cause memory outside themalloced space to be accessed.- Overrides:
setIntin classCPtr- Parameters:
offset- byte offset from pointer at whichvaluemust be setvalue-intvalue to set- See Also:
CPtr.setInt(int, int)
-
setLong
public void setLong(int offset, long value)Indirect the C pointer tomallocspace, a laCPtr.setLong. But this method performs a bounds checks to ensure that the indirection does not cause memory outside themalloced space to be accessed.- Overrides:
setLongin classCPtr- Parameters:
offset- byte offset from pointer at whichvaluemust be setvalue-longvalue to set- See Also:
CPtr.setLong(int, long)
-
setFloat
public void setFloat(int offset, float value)Indirect the C pointer tomallocspace, a laCPtr.setFloat. But this method performs a bounds checks to ensure that the indirection does not cause memory outside themalloced space to be accessed.- Overrides:
setFloatin classCPtr- Parameters:
offset- byte offset from pointer at whichvaluemust be setvalue-floatvalue to set- See Also:
CPtr.setFloat(int, float)
-
setDouble
public void setDouble(int offset, double value)Indirect the C pointer tomallocspace, a laCPtr.setDouble. But this method performs a bounds checks to ensure that the indirection does not cause memory outside themalloced space to be accessed.- Overrides:
setDoublein classCPtr- Parameters:
offset- byte offset from pointer at whichvaluemust be setvalue-doublevalue to set- See Also:
CPtr.setDouble(int, double)
-
setCPtr
public void setCPtr(int offset, CPtr value)Indirect the C pointer tomallocspace, a laCPtr.setCPtr. But this method performs a bounds checks to ensure that the indirection does not cause memory outside themalloced space to be accessed.- Overrides:
setCPtrin classCPtr- Parameters:
offset- byte offset from pointer at whichvaluemust be setvalue-CPtrvalue to set- See Also:
CPtr.setCPtr(int, com.jstatcom.engine.CPtr)
-
setString
public void setString(int offset, java.lang.String value)Indirect the C pointer tomallocspace, a laCPtr.setString. But this method performs a bounds checks to ensure that the indirection does not cause memory outside themalloced space to be accessed.- Overrides:
setStringin classCPtr- Parameters:
offset- byte offset from pointer at which characters invaluemust be setvalue-Stringvalue to set- See Also:
CPtr.setString(int, java.lang.String)
-
-
DMelt 3.0 © DataMelt by jWork.ORG