Skip to content

Commit ceb8b8e

Browse files
committed
Use unique_ptr instead of new to auto handle memory allocations
1 parent a1b3cff commit ceb8b8e

File tree

12 files changed

+108
-58
lines changed

12 files changed

+108
-58
lines changed

source/adapters/opencl/command_buffer.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferEnqueueExp(
324324
NumberOfQueues, &CLQueue, hCommandBuffer->CLCommandBuffer,
325325
numEventsInWaitList, CLWaitEvents.data(), &Event));
326326
if (phEvent) {
327-
*phEvent = new ur_event_handle_t_(Event, hQueue->Context, hQueue);
327+
auto UREvent = std::make_unique<ur_event_handle_t_>(Event, hQueue->Context, hQueue);
328+
*phEvent = UREvent.release();
328329
}
329330
return UR_RESULT_SUCCESS;
330331
}

source/adapters/opencl/context.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urContextCreate(
4545
cl_context Ctx = clCreateContext(
4646
nullptr, cl_adapter::cast<cl_uint>(DeviceCount), CLDevices.data(),
4747
nullptr, nullptr, cl_adapter::cast<cl_int *>(&Ret));
48-
49-
*phContext = new ur_context_handle_t_(Ctx, DeviceCount, phDevices);
48+
auto URContext = std::make_unique<ur_context_handle_t_>(Ctx, DeviceCount, phDevices);
49+
*phContext = URContext.release();
5050
return mapCLErrorToUR(Ret);
5151
}
5252

@@ -142,7 +142,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urContextCreateWithNativeHandle(
142142
ur_context_handle_t *phContext) {
143143

144144
cl_context NativeHandle = reinterpret_cast<cl_context>(hNativeContext);
145-
*phContext = new ur_context_handle_t_(NativeHandle, numDevices, phDevices);
145+
auto URContext = std::make_unique<ur_context_handle_t_>(NativeHandle, numDevices, phDevices);
146+
*phContext = URContext.release();
146147
return UR_RESULT_SUCCESS;
147148
}
148149

source/adapters/opencl/device.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ urDeviceGet(ur_platform_handle_t hPlatform, ur_device_type_t DeviceType,
8686
cl_device_type DeviceType = hPlatform->Devices[i]->Type;
8787
if (DeviceType == Type || Type == CL_DEVICE_TYPE_ALL) {
8888
if (phDevices) {
89-
phDevices[DeviceNumIter] = hPlatform->Devices[i];
89+
phDevices[DeviceNumIter] = hPlatform->Devices[i].get();
9090
}
9191
DeviceNumIter++;
9292
}
@@ -999,8 +999,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urDevicePartition(
999999
CLNumDevicesRet,
10001000
CLSubDevices.data(), nullptr));
10011001
for (uint32_t i = 0; i < NumDevices; i++) {
1002-
phSubDevices[i] =
1003-
new ur_device_handle_t_(CLSubDevices[i], hDevice->Platform, hDevice);
1002+
auto URSubDevice = std::make_unique<ur_device_handle_t_>(CLSubDevices[i], hDevice->Platform, hDevice);
1003+
phSubDevices[i] = URSubDevice.release();
10041004
}
10051005
}
10061006

@@ -1033,7 +1033,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceCreateWithNativeHandle(
10331033
ur_native_handle_t hNativeDevice, ur_platform_handle_t hPlatform,
10341034
const ur_device_native_properties_t *, ur_device_handle_t *phDevice) {
10351035
cl_device_id NativeHandle = reinterpret_cast<cl_device_id>(hNativeDevice);
1036-
*phDevice = new ur_device_handle_t_(NativeHandle, hPlatform, nullptr);
1036+
auto URDevice = std::make_unique<ur_device_handle_t_>(NativeHandle, hPlatform, nullptr);
1037+
*phDevice = URDevice.release();
10371038
return UR_RESULT_SUCCESS;
10381039
}
10391040

source/adapters/opencl/enqueue.cpp

Lines changed: 40 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueKernelLaunch(
4545
pGlobalWorkOffset, pGlobalWorkSize, pLocalWorkSize, numEventsInWaitList,
4646
CLWaitEvents.data(), &Event));
4747
if (phEvent) {
48-
*phEvent = new ur_event_handle_t_(Event, hQueue->Context, hQueue);
48+
auto UREvent = std::make_unique<ur_event_handle_t_>(Event, hQueue->Context, hQueue);
49+
*phEvent = UREvent.release();
4950
}
5051
return UR_RESULT_SUCCESS;
5152
}
@@ -61,7 +62,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueEventsWait(
6162
CL_RETURN_ON_FAILURE(clEnqueueMarkerWithWaitList(
6263
hQueue->get(), numEventsInWaitList, CLWaitEvents.data(), &Event));
6364
if (phEvent) {
64-
*phEvent = new ur_event_handle_t_(Event, hQueue->Context, hQueue);
65+
auto UREvent = std::make_unique<ur_event_handle_t_>(Event, hQueue->Context, hQueue);
66+
*phEvent = UREvent.release();
6567
}
6668
return UR_RESULT_SUCCESS;
6769
}
@@ -77,7 +79,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueEventsWaitWithBarrier(
7779
CL_RETURN_ON_FAILURE(clEnqueueBarrierWithWaitList(
7880
hQueue->get(), numEventsInWaitList, CLWaitEvents.data(), &Event));
7981
if (phEvent) {
80-
*phEvent = new ur_event_handle_t_(Event, hQueue->Context, hQueue);
82+
auto UREvent = std::make_unique<ur_event_handle_t_>(Event, hQueue->Context, hQueue);
83+
*phEvent = UREvent.release();
8184
}
8285
return UR_RESULT_SUCCESS;
8386
}
@@ -95,7 +98,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueMemBufferRead(
9598
hQueue->get(), hBuffer->get(), blockingRead, offset, size, pDst,
9699
numEventsInWaitList, CLWaitEvents.data(), &Event));
97100
if (phEvent) {
98-
*phEvent = new ur_event_handle_t_(Event, hQueue->Context, hQueue);
101+
auto UREvent = std::make_unique<ur_event_handle_t_>(Event, hQueue->Context, hQueue);
102+
*phEvent = UREvent.release();
99103
}
100104
return UR_RESULT_SUCCESS;
101105
}
@@ -113,7 +117,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueMemBufferWrite(
113117
hQueue->get(), hBuffer->get(), blockingWrite, offset, size, pSrc,
114118
numEventsInWaitList, CLWaitEvents.data(), &Event));
115119
if (phEvent) {
116-
*phEvent = new ur_event_handle_t_(Event, hQueue->Context, hQueue);
120+
auto UREvent = std::make_unique<ur_event_handle_t_>(Event, hQueue->Context, hQueue);
121+
*phEvent = UREvent.release();
117122
}
118123
return UR_RESULT_SUCCESS;
119124
}
@@ -139,7 +144,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueMemBufferReadRect(
139144
Region, bufferRowPitch, bufferSlicePitch, hostRowPitch, hostSlicePitch,
140145
pDst, numEventsInWaitList, CLWaitEvents.data(), &Event));
141146
if (phEvent) {
142-
*phEvent = new ur_event_handle_t_(Event, hQueue->Context, hQueue);
147+
auto UREvent = std::make_unique<ur_event_handle_t_>(Event, hQueue->Context, hQueue);
148+
*phEvent = UREvent.release();
143149
}
144150
return UR_RESULT_SUCCESS;
145151
}
@@ -165,7 +171,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueMemBufferWriteRect(
165171
Region, bufferRowPitch, bufferSlicePitch, hostRowPitch, hostSlicePitch,
166172
pSrc, numEventsInWaitList, CLWaitEvents.data(), &Event));
167173
if (phEvent) {
168-
*phEvent = new ur_event_handle_t_(Event, hQueue->Context, hQueue);
174+
auto UREvent = std::make_unique<ur_event_handle_t_>(Event, hQueue->Context, hQueue);
175+
*phEvent = UREvent.release();
169176
}
170177
return UR_RESULT_SUCCESS;
171178
}
@@ -184,7 +191,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueMemBufferCopy(
184191
hQueue->get(), hBufferSrc->get(), hBufferDst->get(), srcOffset, dstOffset,
185192
size, numEventsInWaitList, CLWaitEvents.data(), &Event));
186193
if (phEvent) {
187-
*phEvent = new ur_event_handle_t_(Event, hQueue->Context, hQueue);
194+
auto UREvent = std::make_unique<ur_event_handle_t_>(Event, hQueue->Context, hQueue);
195+
*phEvent = UREvent.release();
188196
}
189197
return UR_RESULT_SUCCESS;
190198
}
@@ -209,7 +217,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueMemBufferCopyRect(
209217
Region, srcRowPitch, srcSlicePitch, dstRowPitch, dstSlicePitch,
210218
numEventsInWaitList, CLWaitEvents.data(), &Event));
211219
if (phEvent) {
212-
*phEvent = new ur_event_handle_t_(Event, hQueue->Context, hQueue);
220+
auto UREvent = std::make_unique<ur_event_handle_t_>(Event, hQueue->Context, hQueue);
221+
*phEvent = UREvent.release();
213222
}
214223
return UR_RESULT_SUCCESS;
215224
}
@@ -231,7 +240,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueMemBufferFill(
231240
hQueue->get(), hBuffer->get(), pPattern, patternSize, offset, size,
232241
numEventsInWaitList, CLWaitEvents.data(), &Event));
233242
if (phEvent) {
234-
*phEvent = new ur_event_handle_t_(Event, hQueue->Context, hQueue);
243+
auto UREvent = std::make_unique<ur_event_handle_t_>(Event, hQueue->Context, hQueue);
244+
*phEvent = UREvent.release();
235245
}
236246
return UR_RESULT_SUCCESS;
237247
}
@@ -271,7 +281,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueMemBufferFill(
271281
}
272282

273283
if (phEvent) {
274-
*phEvent = new ur_event_handle_t_(WriteEvent, hQueue->Context, hQueue);
284+
auto UREvent = std::make_unique<ur_event_handle_t_>(WriteEvent, hQueue->Context, hQueue);
285+
*phEvent = UREvent.release();
275286
} else {
276287
CL_RETURN_ON_FAILURE(clReleaseEvent(WriteEvent));
277288
}
@@ -295,7 +306,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueMemImageRead(
295306
hQueue->get(), hImage->get(), blockingRead, Origin, Region, rowPitch,
296307
slicePitch, pDst, numEventsInWaitList, CLWaitEvents.data(), &Event));
297308
if (phEvent) {
298-
*phEvent = new ur_event_handle_t_(Event, hQueue->Context, hQueue);
309+
auto UREvent = std::make_unique<ur_event_handle_t_>(Event, hQueue->Context, hQueue);
310+
*phEvent = UREvent.release();
299311
}
300312
return UR_RESULT_SUCCESS;
301313
}
@@ -316,7 +328,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueMemImageWrite(
316328
hQueue->get(), hImage->get(), blockingWrite, Origin, Region, rowPitch,
317329
slicePitch, pSrc, numEventsInWaitList, CLWaitEvents.data(), &Event));
318330
if (phEvent) {
319-
*phEvent = new ur_event_handle_t_(Event, hQueue->Context, hQueue);
331+
auto UREvent = std::make_unique<ur_event_handle_t_>(Event, hQueue->Context, hQueue);
332+
*phEvent = UREvent.release();
320333
}
321334
return UR_RESULT_SUCCESS;
322335
}
@@ -339,7 +352,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueMemImageCopy(
339352
hQueue->get(), hImageSrc->get(), hImageDst->get(), SrcOrigin, DstOrigin,
340353
Region, numEventsInWaitList, CLWaitEvents.data(), &Event));
341354
if (phEvent) {
342-
*phEvent = new ur_event_handle_t_(Event, hQueue->Context, hQueue);
355+
auto UREvent = std::make_unique<ur_event_handle_t_>(Event, hQueue->Context, hQueue);
356+
*phEvent = UREvent.release();
343357
}
344358
return UR_RESULT_SUCCESS;
345359
}
@@ -360,7 +374,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueMemBufferMap(
360374
numEventsInWaitList, CLWaitEvents.data(),
361375
&Event, &Err);
362376
if (phEvent) {
363-
*phEvent = new ur_event_handle_t_(Event, hQueue->Context, hQueue);
377+
auto UREvent = std::make_unique<ur_event_handle_t_>(Event, hQueue->Context, hQueue);
378+
*phEvent = UREvent.release();
364379
}
365380
return mapCLErrorToUR(Err);
366381
}
@@ -378,7 +393,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueMemUnmap(
378393
pMappedPtr, numEventsInWaitList,
379394
CLWaitEvents.data(), &Event));
380395
if (phEvent) {
381-
*phEvent = new ur_event_handle_t_(Event, hQueue->Context, hQueue);
396+
auto UREvent = std::make_unique<ur_event_handle_t_>(Event, hQueue->Context, hQueue);
397+
*phEvent = UREvent.release();
382398
}
383399
return UR_RESULT_SUCCESS;
384400
}
@@ -406,7 +422,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueDeviceGlobalVariableWrite(
406422
Res = F(hQueue->get(), hProgram->get(), name, blockingWrite, count, offset,
407423
pSrc, numEventsInWaitList, CLWaitEvents.data(), &Event);
408424
if (phEvent) {
409-
*phEvent = new ur_event_handle_t_(Event, hQueue->Context, hQueue);
425+
auto UREvent = std::make_unique<ur_event_handle_t_>(Event, hQueue->Context, hQueue);
426+
*phEvent = UREvent.release();
410427
}
411428
return mapCLErrorToUR(Res);
412429
}
@@ -434,7 +451,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueDeviceGlobalVariableRead(
434451
Res = F(hQueue->get(), hProgram->get(), name, blockingRead, count, offset,
435452
pDst, numEventsInWaitList, CLWaitEvents.data(), &Event);
436453
if (phEvent) {
437-
*phEvent = new ur_event_handle_t_(Event, hQueue->Context, hQueue);
454+
auto UREvent = std::make_unique<ur_event_handle_t_>(Event, hQueue->Context, hQueue);
455+
*phEvent = UREvent.release();
438456
}
439457
return mapCLErrorToUR(Res);
440458
}
@@ -463,7 +481,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueReadHostPipe(
463481
blocking, pDst, size, numEventsInWaitList,
464482
CLWaitEvents.data(), &Event));
465483
if (phEvent) {
466-
*phEvent = new ur_event_handle_t_(Event, hQueue->Context, hQueue);
484+
auto UREvent = std::make_unique<ur_event_handle_t_>(Event, hQueue->Context, hQueue);
485+
*phEvent = UREvent.release();
467486
}
468487
}
469488

@@ -494,7 +513,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueWriteHostPipe(
494513
blocking, pSrc, size, numEventsInWaitList,
495514
CLWaitEvents.data(), &Event));
496515
if (phEvent) {
497-
*phEvent = new ur_event_handle_t_(Event, hQueue->Context, hQueue);
516+
auto UREvent = std::make_unique<ur_event_handle_t_>(Event, hQueue->Context, hQueue);
517+
*phEvent = UREvent.release();
498518
}
499519
}
500520

source/adapters/opencl/event.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urEventCreateWithNativeHandle(
115115
const ur_event_native_properties_t *pProperties,
116116
ur_event_handle_t *phEvent) {
117117
cl_event NativeHandle = reinterpret_cast<cl_event>(hNativeEvent);
118-
*phEvent = new ur_event_handle_t_(NativeHandle, hContext, nullptr);
118+
auto UREvent = std::make_unique<ur_event_handle_t_>(NativeHandle, hContext, nullptr);
119+
*phEvent = UREvent.release();
119120
if (!pProperties || !pProperties->isNativeHandleOwned) {
120121
return urEventRetain(*phEvent);
121122
}

source/adapters/opencl/memory.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urMemBufferCreate(
266266
cl_mem Buffer = FuncPtr(
267267
CLContext, PropertiesIntel.data(), static_cast<cl_mem_flags>(flags),
268268
size, pProperties->pHost, cl_adapter::cast<cl_int *>(&RetErr));
269-
*phBuffer = new ur_mem_handle_t_(Buffer, hContext);
269+
auto URMem = std::make_unique<ur_mem_handle_t_>(Buffer, hContext);
270+
*phBuffer = URMem.release();
270271
return mapCLErrorToUR(RetErr);
271272
}
272273
}
@@ -276,7 +277,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urMemBufferCreate(
276277
clCreateBuffer(hContext->get(), static_cast<cl_mem_flags>(flags), size,
277278
HostPtr, cl_adapter::cast<cl_int *>(&RetErr));
278279
CL_RETURN_ON_FAILURE(RetErr);
279-
*phBuffer = new ur_mem_handle_t_(Buffer, hContext);
280+
auto URMem = std::make_unique<ur_mem_handle_t_>(Buffer, hContext);
281+
*phBuffer = URMem.release();
280282

281283
return UR_RESULT_SUCCESS;
282284
}
@@ -296,7 +298,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urMemImageCreate(
296298
clCreateImage(hContext->get(), MapFlags, &ImageFormat, &ImageDesc, pHost,
297299
cl_adapter::cast<cl_int *>(&RetErr));
298300
CL_RETURN_ON_FAILURE(RetErr);
299-
*phMem = new ur_mem_handle_t_(Mem, hContext);
301+
auto URMem = std::make_unique<ur_mem_handle_t_>(Mem, hContext);
302+
*phMem = URMem.release();
300303

301304
return UR_RESULT_SUCCESS;
302305
}
@@ -344,7 +347,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urMemBufferCreateWithNativeHandle(
344347
ur_native_handle_t hNativeMem, ur_context_handle_t hContext,
345348
const ur_mem_native_properties_t *pProperties, ur_mem_handle_t *phMem) {
346349
cl_mem NativeHandle = reinterpret_cast<cl_mem>(hNativeMem);
347-
*phMem = new ur_mem_handle_t_(NativeHandle, hContext);
350+
auto URMem = std::make_unique<ur_mem_handle_t_>(NativeHandle, hContext);
351+
*phMem = URMem.release();
348352
if (!pProperties || !pProperties->isNativeHandleOwned) {
349353
return urMemRetain(*phMem);
350354
}
@@ -357,7 +361,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urMemImageCreateWithNativeHandle(
357361
[[maybe_unused]] const ur_image_desc_t *pImageDesc,
358362
const ur_mem_native_properties_t *pProperties, ur_mem_handle_t *phMem) {
359363
cl_mem NativeHandle = reinterpret_cast<cl_mem>(hNativeMem);
360-
*phMem = new ur_mem_handle_t_(NativeHandle, hContext);
364+
auto URMem = std::make_unique<ur_mem_handle_t_>(NativeHandle, hContext);
365+
*phMem = URMem.release();
361366
if (!pProperties || !pProperties->isNativeHandleOwned) {
362367
return urMemRetain(*phMem);
363368
}

source/adapters/opencl/platform.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ UR_APIEXPORT ur_result_t UR_APICALL
8787
urPlatformGet(ur_adapter_handle_t *, uint32_t, uint32_t NumEntries,
8888
ur_platform_handle_t *phPlatforms, uint32_t *pNumPlatforms) {
8989

90-
static std::vector<ur_platform_handle_t> URPlatforms;
90+
static std::vector<std::unique_ptr<ur_platform_handle_t_>> URPlatforms;
9191
static std::once_flag InitFlag;
9292
static uint32_t NumPlatforms = 0;
9393
cl_int Result = CL_SUCCESS;
@@ -107,7 +107,7 @@ urPlatformGet(ur_adapter_handle_t *, uint32_t, uint32_t NumEntries,
107107
}
108108
URPlatforms.resize(NumPlatforms);
109109
for (uint32_t i = 0; i < NumPlatforms; i++) {
110-
URPlatforms[i] = new ur_platform_handle_t_(CLPlatforms[i]);
110+
URPlatforms[i] = std::make_unique<ur_platform_handle_t_>(CLPlatforms[i]);
111111
}
112112
return Result;
113113
},
@@ -125,7 +125,7 @@ urPlatformGet(ur_adapter_handle_t *, uint32_t, uint32_t NumEntries,
125125
}
126126
if (NumEntries && phPlatforms) {
127127
for (uint32_t i = 0; i < NumEntries; i++) {
128-
phPlatforms[i] = URPlatforms[i];
128+
phPlatforms[i] = URPlatforms[i].get();
129129
}
130130
}
131131
return mapCLErrorToUR(Result);
@@ -142,7 +142,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urPlatformCreateWithNativeHandle(
142142
ur_platform_handle_t *phPlatform) {
143143
cl_platform_id NativeHandle =
144144
reinterpret_cast<cl_platform_id>(hNativePlatform);
145-
*phPlatform = new ur_platform_handle_t_(NativeHandle);
145+
auto URPlatform = std::make_unique<ur_platform_handle_t_>(NativeHandle);
146+
*phPlatform = URPlatform.release();
146147
return UR_RESULT_SUCCESS;
147148
}
148149

source/adapters/opencl/platform.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ struct ur_platform_handle_t_ {
175175
using native_type = cl_platform_id;
176176
native_type Platform = nullptr;
177177
std::unique_ptr<cl_adapter::ExtFuncPtrT> ExtFuncPtr;
178-
std::vector<ur_device_handle_t> Devices;
178+
std::vector<std::unique_ptr<ur_device_handle_t_>> Devices;
179179

180180
ur_platform_handle_t_(native_type Plat) : Platform(Plat) {
181181
ExtFuncPtr = std::make_unique<cl_adapter::ExtFuncPtrT>();
@@ -209,9 +209,9 @@ struct ur_platform_handle_t_ {
209209
CL_RETURN_ON_FAILURE(clGetDeviceIDs(Platform, CL_DEVICE_TYPE_ALL, DeviceNum,
210210
CLDevices.data(), nullptr));
211211

212-
Devices = std::vector<ur_device_handle_t>(DeviceNum);
212+
Devices.resize(DeviceNum);
213213
for (size_t i = 0; i < DeviceNum; i++) {
214-
Devices[i] = new ur_device_handle_t_(CLDevices[i], this, nullptr);
214+
Devices[i] = std::make_unique<ur_device_handle_t_>(CLDevices[i], this, nullptr);
215215
}
216216

217217
return UR_RESULT_SUCCESS;

0 commit comments

Comments
 (0)