From 7d3cca2471777a26f90c15aa435c8b50ad6133ca Mon Sep 17 00:00:00 2001 From: Markus Mohrhard Date: Tue, 17 Sep 2013 19:49:20 +0200 Subject: fix another memory leak Change-Id: I6761bcc137934b02815ce10d43f3bc9bee7a1b90 --- sc/source/core/opencl/openclwrapper.cxx | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'sc') 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 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; } -- cgit