Added BufferChecks.checkNullTerminated
This commit is contained in:
parent
9c337a25eb
commit
dcb726d7da
|
@ -58,6 +58,15 @@ public class BufferChecks {
|
||||||
*/
|
*/
|
||||||
private static final int DEFAULT_BUFFER_SIZE = 4;
|
private static final int DEFAULT_BUFFER_SIZE = 4;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper methods to ensure a ByteBuffer is null-terminated
|
||||||
|
*/
|
||||||
|
public static void checkNullTerminated(ByteBuffer buf) {
|
||||||
|
if (buf.get(buf.limit() - 1) != 0) {
|
||||||
|
throw new IllegalArgumentException("Missing null termination");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper methods to ensure a buffer is direct or null.
|
* Helper methods to ensure a buffer is direct or null.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue