summaryrefslogtreecommitdiffstats
path: root/src/com/mbien/opencl/CLUtils.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/mbien/opencl/CLUtils.java')
-rw-r--r--src/com/mbien/opencl/CLUtils.java12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/com/mbien/opencl/CLUtils.java b/src/com/mbien/opencl/CLUtils.java
index c19292b6..a926e8ed 100644
--- a/src/com/mbien/opencl/CLUtils.java
+++ b/src/com/mbien/opencl/CLUtils.java
@@ -1,5 +1,7 @@
package com.mbien.opencl;
+import java.nio.ByteBuffer;
+
/**
*
* @author Michael Bien
@@ -10,4 +12,14 @@ class CLUtils {
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
+ chars.get(array).rewind();
+ return new String(array, 0, clLength-1);
+ }
+ }
+
}