summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2013-09-17 19:49:20 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2013-09-19 17:03:26 +0200
commit7d3cca2471777a26f90c15aa435c8b50ad6133ca (patch)
treecf7391724b8e75de272bf9e07a0f0e1fcfcd5824 /sc
parent29e0843f323c54f9dea9e763a7300bf5fcc2014b (diff)
fix another memory leak
Change-Id: I6761bcc137934b02815ce10d43f3bc9bee7a1b90
Diffstat (limited to 'sc')
-rw-r--r--sc/source/core/opencl/openclwrapper.cxx16
1 files changed, 6 insertions, 10 deletions
diff --git a/sc/source/core/opencl/openclwrapper.cxx b/sc/source/core/opencl/openclwrapper.cxx
index 2ec204622d0c..98ef0d238147 100644
--- a/sc/source/core/opencl/openclwrapper.cxx
+++ b/sc/source/core/opencl/openclwrapper.cxx
@@ -418,7 +418,7 @@ int OpenclDevice::compileKernelFile( GPUEnv *gpuInfo, const char *buildOption )
{
cl_int clStatus = 0;
size_t length;
- char *buildLog = NULL, *binary;
+ char *binary;
const char *source;
int b_error, binary_status, binaryExisted, idx;
cl_uint numDevices;
@@ -526,20 +526,17 @@ int OpenclDevice::compileKernelFile( GPUEnv *gpuInfo, const char *buildOption )
printf("opencl create build log fail\n");
return 0;
}
- buildLog = (char*) malloc( length );
- if ( buildLog == (char*) NULL )
- {
- return 0;
- }
+
+ boost::scoped_array<char> buildLog(new char[length]);
if ( !gpuInfo->mnIsUserCreated )
{
clStatus = clGetProgramBuildInfo( gpuInfo->mpArryPrograms[idx], gpuInfo->mpArryDevsID[0],
- CL_PROGRAM_BUILD_LOG, length, buildLog, &length );
+ CL_PROGRAM_BUILD_LOG, length, buildLog.get(), &length );
}
else
{
clStatus = clGetProgramBuildInfo( gpuInfo->mpArryPrograms[idx], gpuInfo->mpDevID,
- CL_PROGRAM_BUILD_LOG, length, buildLog, &length );
+ CL_PROGRAM_BUILD_LOG, length, buildLog.get(), &length );
}
if ( clStatus != CL_SUCCESS )
{
@@ -550,11 +547,10 @@ int OpenclDevice::compileKernelFile( GPUEnv *gpuInfo, const char *buildOption )
fd1 = fopen( "kernel-build.log", "w+" );
if ( fd1 != NULL )
{
- fwrite( buildLog, sizeof(char), length, fd1 );
+ fwrite( buildLog.get(), sizeof(char), length, fd1 );
fclose( fd1 );
}
- free( buildLog );
return 0;
}