/** * Indirect the native pointer to <code>malloc</code> space, a la * <code>Pointer.write</code>. But this method performs a bounds * checks to ensure that the indirection does not cause memory outside the * <code>malloc</code>ed space to be accessed. * * @see Pointer#write(long,int[],int,int) */ @Override public void write(long bOff, int[] buf, int index, int length) { boundsCheck(bOff, length * 4L); super.write(bOff, buf, index, length); }
/** * Indirect the native pointer to <code>malloc</code> space, a la * <code>Pointer.write</code>. But this method performs a bounds * checks to ensure that the indirection does not cause memory outside the * <code>malloc</code>ed space to be accessed. * * @see Pointer#write(long,long[],int,int) */ @Override public void write(long bOff, long[] buf, int index, int length) { boundsCheck(bOff, length * 8L); super.write(bOff, buf, index, length); }
/** * Indirect the native pointer to <code>malloc</code> space, a la * <code>Pointer.write</code>. But this method performs a bounds * checks to ensure that the indirection does not cause memory outside the * <code>malloc</code>ed space to be accessed. * * @see Pointer#write(long,byte[],int,int) */ @Override public void write(long bOff, byte[] buf, int index, int length) { boundsCheck(bOff, length * 1L); super.write(bOff, buf, index, length); }
/** * Indirect the native pointer to <code>malloc</code> space, a la * <code>Pointer.write</code>. But this method performs a bounds * checks to ensure that the indirection does not cause memory outside the * <code>malloc</code>ed space to be accessed. * * @see Pointer#write(long,char[],int,int) */ @Override public void write(long bOff, char[] buf, int index, int length) { boundsCheck(bOff, length * 2L); super.write(bOff, buf, index, length); }
/** * Indirect the native pointer to <code>malloc</code> space, a la * <code>Pointer.write</code>. But this method performs a bounds * checks to ensure that the indirection does not cause memory outside the * <code>malloc</code>ed space to be accessed. * * @see Pointer#write(long,float[],int,int) */ @Override public void write(long bOff, float[] buf, int index, int length) { boundsCheck(bOff, length * 4L); super.write(bOff, buf, index, length); }
/** * Indirect the native pointer to <code>malloc</code> space, a la * <code>Pointer.write</code>. But this method performs a bounds * checks to ensure that the indirection does not cause memory outside the * <code>malloc</code>ed space to be accessed. * * @see Pointer#write(long,double[],int,int) */ @Override public void write(long bOff, double[] buf, int index, int length) { boundsCheck(bOff, length * 8L); super.write(bOff, buf, index, length); }
/** * Indirect the native pointer to <code>malloc</code> space, a la * <code>Pointer.write</code>. But this method performs a bounds * checks to ensure that the indirection does not cause memory outside the * <code>malloc</code>ed space to be accessed. * * @see Pointer#write(long,short[],int,int) */ @Override public void write(long bOff, short[] buf, int index, int length) { boundsCheck(bOff, length * 2L); super.write(bOff, buf, index, length); }
private void init(Pointer[] els) { elements = new Memory(Native.POINTER_SIZE * els.length); elements.write(0, els, 0, els.length); write(); }
/** * Copy string <code>value</code> to the location being pointed to, using * the requested encoding. * * @param offset byte offset from pointer at which characters in * <code>value</code> must be set * @param value <code>java.lang.String</code> value to set * @param encoding desired encoding */ public void setString(long offset, String value, String encoding) { byte[] data = Native.getBytes(value, encoding); write(offset, data, 0, data.length); setByte(offset + data.length, (byte)0); }
/** Create a native string (NUL-terminated array of <code>char</code>), * using the requested encoding. */ public NativeString(String string, String encoding) { if (string == null) { throw new NullPointerException("String must not be null"); } // Allocate the memory to hold the string. Note, we have to // make this 1 element longer in order to accommodate the terminating // NUL (which is generated in Pointer.setString()). this.encoding = encoding; if (WIDE_STRING.equals(this.encoding)) { int len = (string.length() + 1 ) * Native.WCHAR_SIZE; pointer = new StringMemory(len); pointer.setWideString(0, string); } else { byte[] data = Native.getBytes(string, encoding); pointer = new StringMemory(data.length + 1); pointer.write(0, data, 0, data.length); pointer.setByte(data.length, (byte)0); } }
if (cls == byte.class) { byte[] buf = (byte[])value; write(offset, buf, 0, buf.length); } else if (cls == short.class) { short[] buf = (short[])value; write(offset, buf, 0, buf.length); } else if (cls == char.class) { char[] buf = (char[])value; write(offset, buf, 0, buf.length); } else if (cls == int.class) { int[] buf = (int[])value; write(offset, buf, 0, buf.length); } else if (cls == long.class) { long[] buf = (long[])value; write(offset, buf, 0, buf.length); } else if (cls == float.class) { float[] buf = (float[])value; write(offset, buf, 0, buf.length); } else if (cls == double.class) { double[] buf = (double[])value; write(offset, buf, 0, buf.length); } else if (Pointer.class.isAssignableFrom(cls)) { Pointer[] buf = (Pointer[])value; write(offset, buf, 0, buf.length); } else if (Structure.class.isAssignableFrom(cls)) { Structure[] sbuf = (Structure[])value; write(offset, buf, 0, buf.length); } else {
this.memory.write(0, buf, 0, buf.length);
byte[] buf = new byte[s.size()]; ((Pointer)value).read(0, buf, 0, buf.length); s.getPointer().write(0, buf, 0, buf.length); s.read(); value = s;
/** * Indirect the native pointer to <code>malloc</code> space, a la * <code>Pointer.write</code>. But this method performs a bounds * checks to ensure that the indirection does not cause memory outside the * <code>malloc</code>ed space to be accessed. * * @see Pointer#write(long,double[],int,int) */ public void write(long bOff, double[] buf, int index, int length) { boundsCheck(bOff, length * 8); super.write(bOff, buf, index, length); }
public RASEAPINFO(byte [] data) { pbEapInfo = new Memory(data.length); pbEapInfo.write(0, data, 0, data.length); dwSizeofEapInfo = data.length; allocateMemory(); }
public DATA_BLOB(byte [] data) { pbData = new Memory(data.length); pbData.write(0, data, 0, data.length); cbData = data.length; allocateMemory(); }
public void setRgdispidNamedArgs(DISPID[] namedArgs) { if(namedArgs == null) { namedArgs = new DISPID[0]; } cNamedArgs = new UINT(namedArgs.length); rgdispidNamedArgs = new Memory(DISPID.SIZE * namedArgs.length); int[] rawData = new int[namedArgs.length]; for(int i = 0; i < rawData.length; i++) { rawData[i] = namedArgs[i].intValue(); } rgdispidNamedArgs.write(0, rawData, 0, namedArgs.length); }
private void setBytesSockopt(int option, byte[] optval) { NativeLong length = new NativeLong(optval.length); Pointer value = null; if (optval.length > 0) { value = new Memory(optval.length); value.write(0, optval, 0, optval.length); } else { value = Pointer.NULL; } zmq.zmq_setsockopt(ptr, option, value, length); }
private void setBytesSockopt(int option, byte[] optval) { NativeLong length = new NativeLong(optval.length); Pointer value = null; if (optval.length > 0) { value = new Memory(optval.length); value.write(0, optval, 0, optval.length); } else { value = Pointer.NULL; } zmq.zmq_setsockopt(ptr, option, value, length); }
@Override public AlignedDirectByteBuffer put(byte[] src, int offset, int length) { checkWithinBounds(offset, length, src.length); if (length > remaining()) { throw new BufferOverflowException(); } pointer.write(position, src, offset, length); this.position(position + length); return this; }