From dcb726d7da0f9b884c13f697970aab3eb53f027d Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Wed, 9 Feb 2005 13:44:52 +0000 Subject: [PATCH] Added BufferChecks.checkNullTerminated --- src/java/org/lwjgl/BufferChecks.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/java/org/lwjgl/BufferChecks.java b/src/java/org/lwjgl/BufferChecks.java index 4c723e95..11a5b95d 100644 --- a/src/java/org/lwjgl/BufferChecks.java +++ b/src/java/org/lwjgl/BufferChecks.java @@ -58,6 +58,15 @@ public class BufferChecks { */ 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. */