Kaydet (Commit) 1283dcb0 authored tarafından Kohei Yoshida's avatar Kohei Yoshida

Use scoped_ptr here for exception safety.

Normally scoped_ptr is preferred for local heap objects, than direct
new and delete pair.

Change-Id: Ia8783bfe5f9b37a9bd58f08cce89bf85d88199d1
üst a190ccb3
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
#include <vector> #include <vector>
#include <boost/scoped_ptr.hpp>
#include "opencl_device.hxx" #include "opencl_device.hxx"
...@@ -446,7 +448,7 @@ ds_device getDeviceSelection(const char* sProfilePath, bool bForceSelection) ...@@ -446,7 +448,7 @@ ds_device getDeviceSelection(const char* sProfilePath, bool bForceSelection)
if (!bForceSelection) LOG_PRINTF("[DS] Profile file not available (" << fileName << "); performing profiling."); if (!bForceSelection) LOG_PRINTF("[DS] Profile file not available (" << fileName << "); performing profiling.");
/* Populate input data for micro-benchmark */ /* Populate input data for micro-benchmark */
LibreOfficeDeviceEvaluationIO* testData = new LibreOfficeDeviceEvaluationIO; boost::scoped_ptr<LibreOfficeDeviceEvaluationIO> testData(new LibreOfficeDeviceEvaluationIO);
testData->inputSize = INPUTSIZE; testData->inputSize = INPUTSIZE;
testData->outputSize = OUTPUTSIZE; testData->outputSize = OUTPUTSIZE;
testData->input0.resize(testData->inputSize); testData->input0.resize(testData->inputSize);
...@@ -454,12 +456,12 @@ ds_device getDeviceSelection(const char* sProfilePath, bool bForceSelection) ...@@ -454,12 +456,12 @@ ds_device getDeviceSelection(const char* sProfilePath, bool bForceSelection)
testData->input2.resize(testData->inputSize); testData->input2.resize(testData->inputSize);
testData->input3.resize(testData->inputSize); testData->input3.resize(testData->inputSize);
testData->output.resize(testData->outputSize); testData->output.resize(testData->outputSize);
populateInput(testData); populateInput(testData.get());
/* Perform evaluations */ /* Perform evaluations */
unsigned int numUpdates; unsigned int numUpdates;
status = profileDevices(profile, DS_EVALUATE_ALL, evaluateScoreForDevice, (void*)testData, &numUpdates); status = profileDevices(profile, DS_EVALUATE_ALL, evaluateScoreForDevice, (void*)testData.get(), &numUpdates);
delete testData;
if (DS_SUCCESS == status) if (DS_SUCCESS == status)
{ {
/* Write scores to file */ /* Write scores to file */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment