@@ -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
0 commit comments