diff options
author | Noel Grandin <noel@peralex.com> | 2015-11-10 13:36:34 +0200 |
---|---|---|
committer | Noel Grandin <noelgrandin@gmail.com> | 2015-11-11 07:16:20 +0000 |
commit | db17d3c17c40d6b0e92392cf3c6e343d1d17b771 (patch) | |
tree | 9d562fcf764e7717df9585ef0e735a12ea4aaa16 /opencl | |
parent | 2ce9e4be4a438203382cb9cca824ce3e90647f3a (diff) |
new loplugin: memoryvar
detect when we can convert a new/delete sequence on a local variable to
use std::unique_ptr
Change-Id: Iecae4e4197eccdfacfce2eed39aa4a69e4a660bc
Reviewed-on: https://gerrit.libreoffice.org/19884
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'opencl')
-rw-r--r-- | opencl/source/opencl_device.cxx | 9 | ||||
-rw-r--r-- | opencl/source/openclwrapper.cxx | 5 |
2 files changed, 6 insertions, 8 deletions
diff --git a/opencl/source/opencl_device.cxx b/opencl/source/opencl_device.cxx index 112e03c6d968..9a10d3651d1d 100644 --- a/opencl/source/opencl_device.cxx +++ b/opencl/source/opencl_device.cxx @@ -236,8 +236,8 @@ ds_status evaluateScoreForDevice(ds_device* device, void* evalData) clStatus = clGetDeviceInfo(device->oclDeviceID, CL_DEVICE_EXTENSIONS, 0, nullptr, &aDevExtInfoSize); DS_CHECK_STATUS(clStatus, "evaluateScoreForDevice::clGetDeviceInfo"); - char* aExtInfo = new char[aDevExtInfoSize]; - clStatus = clGetDeviceInfo(device->oclDeviceID, CL_DEVICE_EXTENSIONS, sizeof(char) * aDevExtInfoSize, aExtInfo, nullptr); + std::unique_ptr<char[]> aExtInfo(new char[aDevExtInfoSize]); + clStatus = clGetDeviceInfo(device->oclDeviceID, CL_DEVICE_EXTENSIONS, sizeof(char) * aDevExtInfoSize, aExtInfo.get(), nullptr); DS_CHECK_STATUS(clStatus, "evaluateScoreForDevice::clGetDeviceInfo"); bool bKhrFp64Flag = false; bool bAmdFp64Flag = false; @@ -247,7 +247,7 @@ ds_status evaluateScoreForDevice(ds_device* device, void* evalData) tmpOStrStr << std::dec << INPUTSIZE; tmpStr.append(tmpOStrStr.str()); - if ((std::string(aExtInfo)).find("cl_khr_fp64") != std::string::npos) + if ((std::string(aExtInfo.get())).find("cl_khr_fp64") != std::string::npos) { bKhrFp64Flag = true; //buildOption = "-D KHR_DP_EXTENSION -Dfp_t=double -Dfp_t4=double4 -Dfp_t16=double16"; @@ -255,7 +255,7 @@ ds_status evaluateScoreForDevice(ds_device* device, void* evalData) buildOption = tmpStr.c_str(); SAL_INFO("opencl.device", "... has cl_khr_fp64"); } - else if ((std::string(aExtInfo)).find("cl_amd_fp64") != std::string::npos) + else if ((std::string(aExtInfo.get())).find("cl_amd_fp64") != std::string::npos) { bAmdFp64Flag = true; //buildOption = "-D AMD_DP_EXTENSION -Dfp_t=double -Dfp_t4=double4 -Dfp_t16=double16"; @@ -263,7 +263,6 @@ ds_status evaluateScoreForDevice(ds_device* device, void* evalData) buildOption = tmpStr.c_str(); SAL_INFO("opencl.device", "... has cl_amd_fp64"); } - delete[] aExtInfo; if (!bKhrFp64Flag && !bAmdFp64Flag) { diff --git a/opencl/source/openclwrapper.cxx b/opencl/source/openclwrapper.cxx index 4a05a5feeceb..7bbcb2c3bce3 100644 --- a/opencl/source/openclwrapper.cxx +++ b/opencl/source/openclwrapper.cxx @@ -221,18 +221,17 @@ bool generatBinFromKernelSource( cl_program program, const char * clFileName ) /* copy over the generated binary. */ if ( binarySize != 0 ) { - char *binary = new char[binarySize]; + std::unique_ptr<char[]> binary(new char[binarySize]); clStatus = clGetProgramInfo( program, CL_PROGRAM_BINARIES, sizeof(char *), &binary, nullptr ); CHECK_OPENCL(clStatus,"clGetProgramInfo"); OString fileName = createFileName(pDevID, clFileName); if ( !writeBinaryToFile( fileName, - binary, binarySize ) ) + binary.get(), binarySize ) ) SAL_INFO("opencl.file", "Writing binary file '" << fileName << "': FAIL"); else SAL_INFO("opencl.file", "Writing binary file '" << fileName << "': success"); - delete[] binary; } return true; } |