Skip to content

Commit 87d9e25

Browse files
committed
refactor: migration to std::make_unique C++17
Signed-off-by: Semenov Herman (Семенов Герман) <[email protected]>
1 parent c5d541d commit 87d9e25

File tree

17 files changed

+48
-49
lines changed

17 files changed

+48
-49
lines changed

opencl/source/command_queue/command_queue.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2018-2024 Intel Corporation
2+
* Copyright (C) 2018-2025 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -903,7 +903,7 @@ void CommandQueue::enqueueBlockedMapUnmapOperation(const cl_event *eventWaitList
903903
}
904904

905905
// store task data in event
906-
auto cmd = std::unique_ptr<Command>(new CommandMapUnmap(opType, *memObj, copySize, copyOffset, readOnly, *this));
906+
auto cmd = std::make_unique<CommandMapUnmap>(opType, *memObj, copySize, copyOffset, readOnly, *this);
907907
eventBuilder->getEvent()->setCommand(std::move(cmd));
908908

909909
// bind output event with input events

opencl/source/sharings/va/va_sharing_functions.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2018-2023 Intel Corporation
2+
* Copyright (C) 2018-2025 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -78,7 +78,7 @@ void VASharingFunctions::initFunctions() {
7878
void VASharingFunctions::querySupportedVaImageFormats(VADisplay vaDisplay) {
7979
int maxFormats = this->maxNumImageFormats(vaDisplay);
8080
if (maxFormats > 0) {
81-
std::unique_ptr<VAImageFormat[]> allVaFormats(new VAImageFormat[maxFormats]);
81+
auto allVaFormats = std::make_unique<VAImageFormat[]>(maxFormats);
8282
auto result = this->queryImageFormats(vaDisplay, allVaFormats.get(), &maxFormats);
8383
if (result == VA_STATUS_SUCCESS) {
8484
for (int i = 0; i < maxFormats; i++) {

opencl/source/utilities/cl_logger.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2021-2023 Intel Corporation
2+
* Copyright (C) 2021-2025 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -79,7 +79,7 @@ void ClFileLogger<debugLevel>::dumpKernelArgs(const MultiDispatchInfo *multiDisp
7979
type = "immediate";
8080
auto crossThreadData = kernel->getCrossThreadData();
8181
auto crossThreadDataSize = kernel->getCrossThreadDataSize();
82-
argVal = std::unique_ptr<char[]>(new char[crossThreadDataSize]);
82+
argVal = std::make_unique<char[]>(crossThreadDataSize);
8383

8484
size_t totalArgSize = 0;
8585
for (const auto &element : arg.as<ArgDescValue>().elements) {

shared/offline_compiler/source/ocloc_arg_helper.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2020-2024 Intel Corporation
2+
* Copyright (C) 2020-2025 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -143,7 +143,7 @@ std::vector<char> OclocArgHelper::readBinaryFile(const std::string &filename) {
143143
std::unique_ptr<char[]> OclocArgHelper::loadDataFromFile(const std::string &filename, size_t &retSize) {
144144
if (Source *s = findSourceFile(filename)) {
145145
auto size = s->length;
146-
std::unique_ptr<char[]> ret(new char[size]());
146+
auto ret = std::make_unique<char[]>(size);
147147
memcpy_s(ret.get(), size, s->data, s->length);
148148
retSize = s->length;
149149
return ret;

shared/source/ail/ail_configuration.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2021-2024 Intel Corporation
2+
* Copyright (C) 2021-2025 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -120,8 +120,7 @@ template <PRODUCT_FAMILY product>
120120
class AILConfigurationHw : public AILConfiguration {
121121
public:
122122
static std::unique_ptr<AILConfiguration> create() {
123-
auto ailConfiguration = std::unique_ptr<AILConfiguration>(new AILConfigurationHw());
124-
return ailConfiguration;
123+
return std::make_unique<AILConfigurationHw>();
125124
}
126125

127126
void applyExt(RuntimeCapabilityTable &runtimeCapabilityTable) override;

shared/source/built_ins/built_ins_storage.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2018-2024 Intel Corporation
2+
* Copyright (C) 2018-2025 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -173,8 +173,8 @@ BuiltinResourceT EmbeddedStorage::loadImpl(const std::string &fullResourceName)
173173
}
174174

175175
BuiltinsLib::BuiltinsLib() {
176-
allStorages.push_back(std::unique_ptr<Storage>(new EmbeddedStorage("")));
177-
allStorages.push_back(std::unique_ptr<Storage>(new FileStorage(getDriverInstallationPath())));
176+
allStorages.push_back(std::make_unique<EmbeddedStorage>(""));
177+
allStorages.push_back(std::make_unique<FileStorage>(getDriverInstallationPath()));
178178
}
179179

180180
BuiltinCode BuiltinsLib::getBuiltinCode(EBuiltInOps::Type builtin, BuiltinCode::ECodeType requestedCodeType, Device &device) {

shared/source/command_container/cmdcontainer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019-2024 Intel Corporation
2+
* Copyright (C) 2019-2025 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -120,7 +120,7 @@ CommandContainer::ErrorCode CommandContainer::initialize(Device *device, Allocat
120120

121121
addToResidencyContainer(cmdBufferAllocation);
122122
if (requireHeaps) {
123-
heapHelper = std::unique_ptr<HeapHelper>(new HeapHelper(device->getMemoryManager(), device->getDefaultEngine().commandStreamReceiver->getInternalAllocationStorage(), device->getNumGenericSubDevices() > 1u));
123+
heapHelper = std::make_unique<HeapHelper>(device->getMemoryManager(), device->getDefaultEngine().commandStreamReceiver->getInternalAllocationStorage(), device->getNumGenericSubDevices() > 1u);
124124

125125
for (uint32_t i = 0; i < IndirectHeap::Type::numTypes; i++) {
126126
auto heapType = static_cast<HeapType>(i);
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2018-2022 Intel Corporation
2+
* Copyright (C) 2018-2025 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -9,6 +9,6 @@
99

1010
namespace NEO {
1111
std::unique_ptr<DeferredDeleter> createDeferredDeleter() {
12-
return std::unique_ptr<DeferredDeleter>(new DeferredDeleter());
12+
return std::make_unique<DeferredDeleter>();
1313
}
1414
} // namespace NEO

shared/source/os_interface/linux/drm_memory_manager.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2018-2024 Intel Corporation
2+
* Copyright (C) 2018-2025 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -793,7 +793,7 @@ GraphicsAllocation *DrmMemoryManager::allocatePhysicalDeviceMemory(const Allocat
793793
auto isCoherent = productHelper.isCoherentAllocation(patIndex);
794794
uint32_t handle = ioctlHelper->createGem(bufferSize, static_cast<uint32_t>(allocationData.storageInfo.memoryBanks.to_ulong()), isCoherent);
795795

796-
std::unique_ptr<BufferObject, BufferObject::Deleter> bo(new BufferObject(allocationData.rootDeviceIndex, &drm, patIndex, handle, bufferSize, maxOsContextCount));
796+
auto bo = std::make_unique<BufferObject>(allocationData.rootDeviceIndex, &drm, patIndex, handle, bufferSize, maxOsContextCount);
797797

798798
auto allocation = new DrmAllocation(allocationData.rootDeviceIndex, 1u /*num gmms*/, allocationData.type, bo.get(), nullptr, 0u, bufferSize, memoryPool);
799799
allocation->setDefaultGmm(gmm.release());
@@ -842,7 +842,7 @@ GraphicsAllocation *DrmMemoryManager::allocateMemoryByKMD(const AllocationData &
842842
boType = BufferObject::BOType::legacy;
843843
}
844844

845-
std::unique_ptr<BufferObject, BufferObject::Deleter> bo(new BufferObject(allocationData.rootDeviceIndex, &drm, patIndex, handle, bufferSize, maxOsContextCount));
845+
auto bo = std::make_unique<BufferObject>(allocationData.rootDeviceIndex, &drm, patIndex, handle, bufferSize, maxOsContextCount);
846846
bo->setAddress(gpuRange);
847847
bo->setBOType(boType);
848848

@@ -2683,7 +2683,7 @@ GraphicsAllocation *DrmMemoryManager::createSharedUnifiedMemoryAllocation(const
26832683
return nullptr;
26842684
}
26852685

2686-
std::unique_ptr<BufferObject, BufferObject::Deleter> bo(new BufferObject(allocationData.rootDeviceIndex, &drm, patIndex, handle, currentSize, maxOsContextCount));
2686+
auto bo = std::make_unique<BufferObject>(allocationData.rootDeviceIndex, &drm, patIndex, handle, currentSize, maxOsContextCount);
26872687

26882688
if (vmAdviseAttribute.has_value() && !ioctlHelper->setVmBoAdvise(bo->peekHandle(), vmAdviseAttribute.value(), nullptr)) {
26892689
ioctlHelper->munmapFunction(*this, cpuBasePointer, totalSizeToAlloc);

shared/source/os_interface/linux/ioctl_helper_prelim.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2021-2024 Intel Corporation
2+
* Copyright (C) 2021-2025 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -503,7 +503,7 @@ std::unique_ptr<uint8_t[]> IoctlHelperPrelim20::prepareVmBindExt(const StackVec<
503503
"Alignment of a buffer returned via new[] operator must allow storing the required type!");
504504

505505
const auto bufferSize{sizeof(prelim_drm_i915_vm_bind_ext_uuid) * bindExtHandles.size()};
506-
std::unique_ptr<uint8_t[]> extensionsBuffer{new uint8_t[bufferSize]};
506+
auto extensionsBuffer = std::make_unique<uint8_t[]>(bufferSize);
507507

508508
auto extensions = new (extensionsBuffer.get()) prelim_drm_i915_vm_bind_ext_uuid[bindExtHandles.size()];
509509
std::memset(extensionsBuffer.get(), 0, bufferSize);

0 commit comments

Comments
 (0)