public AutoAllocated(int size) { super(size); // Always clear new structure memory super.clear(); } @Override
/** Zero the full extent of this memory region. */ public void clear() { clear(size); }
@Override protected Memory initialValue() { Memory m = new Memory(4); m.clear(); return m; } };
private MacAddress getMacAddress(String nifName) { Pointer lpAdapter = NativePacketDllMappings.PacketOpenAdapter(nifName); long hFile = -1; if (lpAdapter != null) { if (Native.POINTER_SIZE == 4) { hFile = lpAdapter.getInt(0); } else { hFile = lpAdapter.getLong(0); } } if (hFile == -1L) { int err = Native.getLastError(); logger.error("Unable to open the NIF {}, Error Code: {}", nifName, err); return null; } Memory mem = new Memory(NativePacketDllMappings.PACKET_OID_DATA_SIZE); mem.clear(); PACKET_OID_DATA oidData = new PACKET_OID_DATA(mem); oidData.Length = new NativeLong(6L); oidData.Oid = new NativeLong(0x01010102L); int status = NativePacketDllMappings.PacketRequest(lpAdapter, 0, oidData); NativePacketDllMappings.PacketCloseAdapter(lpAdapter); if (status == 0) { logger.error("Failed to retrieve the link layer address of the NIF: {}", nifName); return null; } else { return MacAddress.getByAddress(oidData.Data); } }
/** * Clears this buffer by setting every state to false. * * @return This instance. */ public GpioBuffer clear() { this.buffer.clear() ; return this ; }
public AutoAllocated(int size) { super(size); // Always clear new structure memory super.clear(); } @Override
/** Zero the full extent of this memory region. */ public void clear() { clear(size); }
/** Zero the full extent of this memory region. */ public void clear() { clear(size); }
@Override protected Memory initialValue() { Memory m = new Memory(4); m.clear(); return m; } };
/** * Basic constructor */ public GpioChipInfo() { this.memory = new Memory( NativeGpioChipInfo.SIZE ) ; this.memory.clear() ; }
/** * Basic constructor. */ public GpioBuffer() { this.buffer = new Memory( SIZE ) ; this.buffer.clear() ; }
/** * Basic constructor, by default lines will be requested as they are. */ public GpioHandleRequest() { this.memory = new Memory( NativeGpioHandleRequest.SIZE ) ; this.memory.clear() ; }
/** * Basic constructor. */ public GpioLineInfo() { this.memory = new Memory( NativeGpioLineInfo.SIZE ) ; this.memory.clear() ; }
ourSharedMemory.clear(); int rc; synchronized (cLibrary) {
ourSharedMemory.clear(); int rc; synchronized (cLibrary) {
public void setValue(String value) { if(value == null) { value = ""; } try { byte[] encodedValue = value.getBytes("UTF-16LE"); // 4 bytes for the length prefix, length for the encoded data, // 2 bytes for the two NULL terminators Memory mem = new Memory(4 + encodedValue.length + 2); mem.clear(); mem.setInt(0, encodedValue.length); mem.write(4, encodedValue, 0, encodedValue.length); this.setPointer(mem.share(4)); } catch (UnsupportedEncodingException ex) { throw new RuntimeException("UTF-16LE charset is not supported", ex); } }
private GpioEventRequest( int line , GpioEdgeDetection edgeDetection , int flags ) { this.memory = new Memory( NativeGpioEventRequest.SIZE ) ; this.memory.clear() ; this.setLine( line ) ; this.setEdgeDetection( edgeDetection ) ; this.setRawFlags( flags ) ; }
private MacAddress getMacAddress(String nifName) { Pointer lpAdapter = NativePacketDllMappings.PacketOpenAdapter(nifName); long hFile = -1; if (lpAdapter != null) { if (Native.POINTER_SIZE == 4) { hFile = lpAdapter.getInt(0); } else { hFile = lpAdapter.getLong(0); } } if (hFile == -1L) { int err = Native.getLastError(); logger.error("Unable to open the NIF {}, Error Code: {}", nifName, err); return null; } Memory mem = new Memory(NativePacketDllMappings.PACKET_OID_DATA_SIZE); mem.clear(); PACKET_OID_DATA oidData = new PACKET_OID_DATA(mem); oidData.Length = new NativeLong(6L); oidData.Oid = new NativeLong(0x01010102L); int status = NativePacketDllMappings.PacketRequest(lpAdapter, 0, oidData); NativePacketDllMappings.PacketCloseAdapter(lpAdapter); if (status == 0) { logger.error("Failed to retrieve the link layer address of the NIF: {}", nifName); return null; } else { return MacAddress.getByAddress(oidData.Data); } }
private static Memory getSecurityDescriptorForFile(final String absoluteFilePath) { final int infoType = OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION; final IntByReference lpnSize = new IntByReference(); boolean succeeded = Advapi32.INSTANCE.GetFileSecurity( absoluteFilePath, infoType, null, 0, lpnSize); if (!succeeded) { final int lastError = Kernel32.INSTANCE.GetLastError(); if (W32Errors.ERROR_INSUFFICIENT_BUFFER != lastError) { throw new Win32Exception(lastError); } } final int nLength = lpnSize.getValue(); final Memory securityDescriptorMemoryPointer = new Memory(nLength); succeeded = Advapi32.INSTANCE.GetFileSecurity( absoluteFilePath, infoType, securityDescriptorMemoryPointer, nLength, lpnSize); if (!succeeded) { securityDescriptorMemoryPointer.clear(); throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); } return securityDescriptorMemoryPointer; }
} finally { if (passwordData != null) { passwordData.clear();