From 6ca42ce154439b8c2f7f76ce4300ae08678f223a Mon Sep 17 00:00:00 2001 From: Michael Bien Date: Fri, 21 Jan 2011 23:45:39 +0100 Subject: missing buffer rewind in source upload code (bug id: #458). --- src/com/jogamp/opencl/CLProgram.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/com') diff --git a/src/com/jogamp/opencl/CLProgram.java b/src/com/jogamp/opencl/CLProgram.java index 548997e8..e74ebed3 100644 --- a/src/com/jogamp/opencl/CLProgram.java +++ b/src/com/jogamp/opencl/CLProgram.java @@ -73,14 +73,19 @@ public class CLProgram extends CLObject implements CLResource { static CLProgram create(CLContext context, String src) { - IntBuffer status = newDirectByteBuffer(4).asIntBuffer(); + IntBuffer status = newDirectIntBuffer(1); + + PointerBuffer length = (PointerBuffer)PointerBuffer.allocateDirect(1).put(0, src.length()); + String[] srcArray = new String[] {src}; + // Create the program - long id = context.cl.clCreateProgramWithSource(context.ID, 1, new String[] {src}, - (PointerBuffer)PointerBuffer.allocateDirect(1).put(src.length()), status); + long id = context.cl.clCreateProgramWithSource(context.ID, 1, srcArray, length, status); int err = status.get(); if(err != CL_SUCCESS) { - throw newException(err, "can not create program with source on "+context); + // don't remove: locks the reference (length and srcArray) + length.rewind(); + throw newException(err, "can not create program with source (length="+srcArray[0].length()+") on "+context); } return new CLProgram(context, id); -- cgit v1.2.3