@@ -172,12 +172,13 @@ protected void setBinaries(Map<CLDevice, byte[]> binaries) {
172172 if (nDevices == 0 )
173173 return ;
174174
175- Pointer <Integer > errBuff = allocateInt ();
175+ ReusablePointers ptrs = ReusablePointers .get ();
176+ Pointer <Integer > pErr = ptrs .pErr ;
176177 int previousAttempts = 0 ;
177178 Pointer <Integer > statuses = allocateInts (nDevices );
178179 do {
179- setEntity (CL .clCreateProgramWithBinary (context .getEntity (), nDevices , deviceIds , lengths , binariesArray , statuses , errBuff ));
180- } while (failedForLackOfMemory (errBuff . get (), previousAttempts ++));
180+ setEntity (CL .clCreateProgramWithBinary (context .getEntity (), nDevices , deviceIds , lengths , binariesArray , statuses , pErr ));
181+ } while (failedForLackOfMemory (pErr . getInt (), previousAttempts ++));
181182 }
182183
183184 /**
@@ -302,12 +303,14 @@ public synchronized void allocate() {
302303 for (int i = 0 ; i < sources .length ; i ++) {
303304 lengths [i ] = sources [i ].length ();
304305 }
305- Pointer <Integer > errBuff = allocateInt ();
306+
307+ ReusablePointers ptrs = ReusablePointers .get ();
308+ Pointer <Integer > pErr = ptrs .pErr ;
306309 cl_program program ;
307310 int previousAttempts = 0 ;
308311 do {
309- program = CL .clCreateProgramWithSource (context .getEntity (), sources .length , pointerToCStrings (sources ), pointerToSizeTs (lengths ), errBuff );
310- } while (failedForLackOfMemory (errBuff . get ( 0 ), previousAttempts ++));
312+ program = CL .clCreateProgramWithSource (context .getEntity (), sources .length , pointerToCStrings (sources ), pointerToSizeTs (lengths ), pErr );
313+ } while (failedForLackOfMemory (pErr . getInt ( ), previousAttempts ++));
311314 setEntity (program );
312315 }
313316
@@ -834,7 +837,7 @@ public CLKernel[] createKernels() throws CLBuildException {
834837 int previousAttempts = 0 ;
835838 while (failedForLackOfMemory (CL .clCreateKernelsInProgram (getEntity (), 0 , null , pCount ), previousAttempts ++)) {}
836839
837- int count = pCount .get ();
840+ int count = pCount .getInt ();
838841 Pointer <cl_kernel > kerns = allocateTypedPointers (cl_kernel .class , count );
839842 previousAttempts = 0 ;
840843 while (failedForLackOfMemory (CL .clCreateKernelsInProgram (getEntity (), count , kerns , pCount ), previousAttempts ++)) {}
@@ -854,12 +857,13 @@ public CLKernel createKernel(String name, Object... args) throws CLBuildExceptio
854857 if (!built )
855858 build ();
856859 }
857- Pointer <Integer > errBuff = allocateInt ();
860+ ReusablePointers ptrs = ReusablePointers .get ();
861+ Pointer <Integer > pErr = ptrs .pErr ;
858862 cl_kernel kernel ;
859863 int previousAttempts = 0 ;
860864 do {
861- kernel = CL .clCreateKernel (getEntity (), pointerToCString (name ), errBuff );
862- } while (failedForLackOfMemory (errBuff . get ( 0 ), previousAttempts ++));
865+ kernel = CL .clCreateKernel (getEntity (), pointerToCString (name ), pErr );
866+ } while (failedForLackOfMemory (pErr . getInt ( ), previousAttempts ++));
863867
864868 CLKernel kn = new CLKernel (this , name , kernel );
865869 if (args .length != 0 )
0 commit comments