Commit 60c701457a646c1ad218d0be85e88eee9273ff1b

Con Kolivas 2012-02-11T16:41:41

Retain cl program after successfully loading a binary image.

diff --git a/ocl.c b/ocl.c
index c8cd2e1..10f42aa 100644
--- a/ocl.c
+++ b/ocl.c
@@ -462,11 +462,17 @@ _clState *initCl(unsigned int gpu, char *name, size_t nameSize)
 			free(binaries[gpu]);
 			goto build;
 		}
+
+		clRetainProgram(clState->program);
+		if (status != CL_SUCCESS) {
+			applog(LOG_ERR, "Error: Retaining Program (clRetainProgram)");
+			return NULL;
+		}
+
 		fclose(binaryfile);
 		if (opt_debug)
 			applog(LOG_DEBUG, "Loaded binary image %s", binaryfilename);
 
-		free(binaries[gpu]);
 		goto built;
 	}
 
@@ -636,9 +642,9 @@ build:
 		}
 		fclose(binaryfile);
 	}
+built:
 	if (binaries[gpu])
 		free(binaries[gpu]);
-built:
 	free(binaries);
 	free(binary_sizes);