summaryrefslogtreecommitdiffstats
path: root/src/com/jogamp/opencl/util/CLUtil.java
diff options
context:
space:
mode:
authorMichael Bien <[email protected]>2011-02-04 22:33:18 +0100
committerMichael Bien <[email protected]>2011-02-04 22:33:18 +0100
commitaec6036ac7c70c905573c5f5f133646555e4a58e (patch)
tree60a53c782502c2efdfa46b56eb20aaaca6a656da /src/com/jogamp/opencl/util/CLUtil.java
parentad554ae820ca353a1796bd750b669c1a00546341 (diff)
device names no longer corrupted on windows.
Diffstat (limited to 'src/com/jogamp/opencl/util/CLUtil.java')
-rw-r--r--src/com/jogamp/opencl/util/CLUtil.java11
1 files changed, 8 insertions, 3 deletions
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);
}
}