aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/com/jogamp/opencl/CLInfoAccessor.java2
-rw-r--r--src/com/jogamp/opencl/util/CLUtil.java11
2 files changed, 9 insertions, 4 deletions
diff --git a/src/com/jogamp/opencl/CLInfoAccessor.java b/src/com/jogamp/opencl/CLInfoAccessor.java
index 24477604..08f8d8a2 100644
--- a/src/com/jogamp/opencl/CLInfoAccessor.java
+++ b/src/com/jogamp/opencl/CLInfoAccessor.java
@@ -77,7 +77,7 @@ abstract class CLInfoAccessor {
checkForError(ret, "error while asking for info string");
int clSize = (int)sizeBuffer.get(0);
- byte[] array = new byte[clSize-1]; // last char is always null
+ byte[] array = new byte[clSize];
buffer.get(array).rewind();
return CLUtil.clString2JavaString(array, clSize);
diff --git a/src/com/jogamp/opencl/util/CLUtil.java b/src/com/jogamp/opencl/util/CLUtil.java
index 3d555cb3..371c493c 100644
--- a/src/com/jogamp/opencl/util/CLUtil.java
+++ b/src/com/jogamp/opencl/util/CLUtil.java
@@ -49,16 +49,21 @@ import java.util.Map;
public class CLUtil {
public static String clString2JavaString(byte[] chars, int clLength) {
- return clLength==0 ? "" : new String(chars, 0, clLength-1);
+
+ // certain char queries on windows always claim to have a fixed length
+ // e.g. (clDeviceInfo(CL_DEVICE_NAME) is always 64.. but luckily they are 0 terminated)
+ while(clLength > 0 && chars[--clLength] == 0);
+
+ return clLength==0 ? "" : new String(chars, 0, clLength+1);
}
public static String clString2JavaString(ByteBuffer chars, int clLength) {
if (clLength==0) {
return "";
}else{
- byte[] array = new byte[clLength-1]; // last char is always null
+ byte[] array = new byte[clLength];
chars.get(array).rewind();
- return new String(array, 0, clLength-1);
+ return clString2JavaString(array, clLength);
}
}