Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/linuxfs_buff_overrun' into linux…
Browse files Browse the repository at this point in the history
…fs_buff_overrun
  • Loading branch information
taartspi committed Mar 3, 2024
2 parents a2f7bc3 + ed208f2 commit 2d30fb0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@ protected synchronized IntBuffer getOffsetsBuffer(int size) {
localOffsetsBuffer.set(buf);
}
return buf;

}


Expand All @@ -245,12 +244,10 @@ protected synchronized ByteBuffer getDataBuffer(int size) {
if (size > localBufferSize)
throw new ScratchBufferOverrun();

// if no buffer exists, one always created.
// if buffer exists and limit is not equal to this getDataBuffer, allocate new
if (buf == null) {
buf = ByteBuffer.allocateDirect(size);
localDataBuffer.set(buf);
} else if(buf.limit() != size){
}else if(buf.limit() != size){
localDataBuffer.remove();
buf = ByteBuffer.allocateDirect(size);
localDataBuffer.set(buf);
Expand All @@ -259,7 +256,6 @@ protected synchronized ByteBuffer getDataBuffer(int size) {
return buf;
}


public static class ScratchBufferOverrun extends IllegalArgumentException {
private static final long serialVersionUID = -418203522640826177L;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ public int readRegister(byte[] register, byte[] buffer, int offset, int length)
short writeLength = (short) register.length;
// two pointers will be used so 2 pairs of offset entries
IntBuffer offsets = IntBuffer.allocate(4);
// create ByteBuffer, load with the write details Matches i2c provider
// create ByteBuffer, load with the write details Matches i2c provider
ByteBuffer ioctlData = ByteBuffer.allocate(2048);
// Ensures Pi BCM little_endian
ioctlData.order(ByteOrder.nativeOrder());
Expand Down

0 comments on commit 2d30fb0

Please sign in to comment.