[Sysman] Replace normal pointers with smart pointers (4/n).

Replacing normal pointers by smart pointers in temperature module of L0 sysman.

Related-To: LOCI-2810

Signed-off-by: Singh, Prasoon <prasoon.singh@intel.com>
This commit is contained in:
Singh, Prasoon
2023-03-06 06:44:23 +00:00
committed by Compute-Runtime-Automation
parent 8119905325
commit 1a6f03c36e
4 changed files with 6 additions and 20 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2022 Intel Corporation
* Copyright (C) 2020-2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -12,18 +12,12 @@
namespace L0 {
TemperatureHandleContext::~TemperatureHandleContext() {
for (Temperature *pTemperature : handleList) {
delete pTemperature;
}
}
TemperatureHandleContext::~TemperatureHandleContext() {}
void TemperatureHandleContext::createHandle(const ze_device_handle_t &deviceHandle, zes_temp_sensors_t type) {
Temperature *pTemperature = new TemperatureImp(deviceHandle, pOsSysman, type);
std::unique_ptr<Temperature> pTemperature = std::make_unique<TemperatureImp>(deviceHandle, pOsSysman, type);
if (pTemperature->initSuccess == true) {
handleList.push_back(pTemperature);
} else {
delete pTemperature;
handleList.push_back(std::move(pTemperature));
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2022 Intel Corporation
* Copyright (C) 2020-2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -42,7 +42,7 @@ struct TemperatureHandleContext {
ze_result_t temperatureGet(uint32_t *pCount, zes_temp_handle_t *phTemperature);
OsSysman *pOsSysman = nullptr;
std::vector<Temperature *> handleList = {};
std::vector<std::unique_ptr<Temperature>> handleList = {};
private:
void createHandle(const ze_device_handle_t &deviceHandle, zes_temp_sensors_t type);

View File

@@ -34,10 +34,6 @@ class SysmanMultiDeviceTemperatureFixture : public SysmanMultiDeviceFixture {
GTEST_SKIP();
}
SysmanMultiDeviceFixture::SetUp();
for (auto &handle : pSysmanDeviceImp->pTempHandleContext->handleList) {
delete handle;
handle = nullptr;
}
pSysmanDeviceImp->pTempHandleContext->handleList.clear();
pFsAccess = std::make_unique<MockTemperatureFsAccess>();
pFsAccessOriginal = pLinuxSysmanImp->pFsAccess;

View File

@@ -32,10 +32,6 @@ class SysmanDeviceTemperatureFixture : public SysmanDeviceFixture {
pOriginalKmdSysManager = pWddmSysmanImp->pKmdSysManager;
pWddmSysmanImp->pKmdSysManager = pKmdSysManager.get();
for (auto handle : pSysmanDeviceImp->pTempHandleContext->handleList) {
delete handle;
}
pSysmanDeviceImp->pTempHandleContext->handleList.clear();
uint32_t subDeviceCount = 0;
// We received a device handle. Check for subdevices in this device