diff --git a/scripts/templates/ldrddi.cpp.mako b/scripts/templates/ldrddi.cpp.mako index b2cf31d7..d95e01a5 100644 --- a/scripts/templates/ldrddi.cpp.mako +++ b/scripts/templates/ldrddi.cpp.mako @@ -360,9 +360,14 @@ namespace loader %endif %if 'range' in item: +## A null [in][optional] array must reach the driver as null. new[0] returns a +## non-null pointer, which for some APIs silently changes the meaning of the +## call: zetContextActivateMetricGroups reads nullptr as "deactivate all +## previously used metric groups", so it would never deactivate anything. +## delete[] on nullptr is a no-op, so the cleanup below needs no change. <% - add_local = True%>// convert loader handles to driver handles - auto ${item['name']}Local = new ${item['type']} [${item['range'][1]}]; + add_local = True%>// convert loader handles to driver handles, preserving a null input array + auto ${item['name']}Local = ( ${item['name']} ) ? new ${item['type']} [${item['range'][1]}] : nullptr; <% arrays_to_delete.append(item['name']+ 'Local') %>for( size_t i = ${item['range'][0]}; ( nullptr != ${item['name']} ) && ( i < ${item['range'][1]} ); ++i ) @@ -413,8 +418,8 @@ namespace loader ## Workaround due to incorrect definition of phWaitEvents in the ze headers which missed the range values. ## To be removed once the headers have been updated in a new spec release. %if re.match(r"\w+CommandListAppendMetricQueryEnd$", th.make_func_name(n, tags, obj)): - // convert loader handles to driver handles - auto phWaitEventsLocal = new ze_event_handle_t [numWaitEvents]; + // convert loader handles to driver handles, preserving a null input array + auto phWaitEventsLocal = ( phWaitEvents ) ? new ze_event_handle_t [numWaitEvents] : nullptr; for( size_t i = 0; ( nullptr != phWaitEvents ) && ( i < numWaitEvents ); ++i ) phWaitEventsLocal[ i ] = reinterpret_cast( phWaitEvents[ i ] )->handle; diff --git a/source/loader/ze_ldrddi.cpp b/source/loader/ze_ldrddi.cpp index 502154b7..1e396cb4 100644 --- a/source/loader/ze_ldrddi.cpp +++ b/source/loader/ze_ldrddi.cpp @@ -1423,8 +1423,8 @@ namespace loader // convert loader handle to driver handle hDriver = reinterpret_cast( hDriver )->handle; - // convert loader handles to driver handles - auto phDevicesLocal = new ze_device_handle_t [numDevices]; + // convert loader handles to driver handles, preserving a null input array + auto phDevicesLocal = ( phDevices ) ? new ze_device_handle_t [numDevices] : nullptr; for( size_t i = 0; ( nullptr != phDevices ) && ( i < numDevices ); ++i ) phDevicesLocal[ i ] = reinterpret_cast( phDevices[ i ] )->handle; @@ -1599,8 +1599,8 @@ namespace loader // convert loader handle to driver handle hCommandQueue = reinterpret_cast( hCommandQueue )->handle; - // convert loader handles to driver handles - auto phCommandListsLocal = new ze_command_list_handle_t [numCommandLists]; + // convert loader handles to driver handles, preserving a null input array + auto phCommandListsLocal = ( phCommandLists ) ? new ze_command_list_handle_t [numCommandLists] : nullptr; for( size_t i = 0; ( nullptr != phCommandLists ) && ( i < numCommandLists ); ++i ) phCommandListsLocal[ i ] = reinterpret_cast( phCommandLists[ i ] )->handle; @@ -1964,8 +1964,8 @@ namespace loader // convert loader handle to driver handle hSignalEvent = ( hSignalEvent ) ? reinterpret_cast( hSignalEvent )->handle : nullptr; - // convert loader handles to driver handles - auto phWaitEventsLocal = new ze_event_handle_t [numWaitEvents]; + // convert loader handles to driver handles, preserving a null input array + auto phWaitEventsLocal = ( phWaitEvents ) ? new ze_event_handle_t [numWaitEvents] : nullptr; for( size_t i = 0; ( nullptr != phWaitEvents ) && ( i < numWaitEvents ); ++i ) phWaitEventsLocal[ i ] = reinterpret_cast( phWaitEvents[ i ] )->handle; @@ -2288,8 +2288,8 @@ namespace loader // convert loader handle to driver handle hSignalEvent = ( hSignalEvent ) ? reinterpret_cast( hSignalEvent )->handle : nullptr; - // convert loader handles to driver handles - auto phWaitEventsLocal = new ze_event_handle_t [numWaitEvents]; + // convert loader handles to driver handles, preserving a null input array + auto phWaitEventsLocal = ( phWaitEvents ) ? new ze_event_handle_t [numWaitEvents] : nullptr; for( size_t i = 0; ( nullptr != phWaitEvents ) && ( i < numWaitEvents ); ++i ) phWaitEventsLocal[ i ] = reinterpret_cast( phWaitEvents[ i ] )->handle; @@ -2329,8 +2329,8 @@ namespace loader // convert loader handle to driver handle hSignalEvent = ( hSignalEvent ) ? reinterpret_cast( hSignalEvent )->handle : nullptr; - // convert loader handles to driver handles - auto phWaitEventsLocal = new ze_event_handle_t [numWaitEvents]; + // convert loader handles to driver handles, preserving a null input array + auto phWaitEventsLocal = ( phWaitEvents ) ? new ze_event_handle_t [numWaitEvents] : nullptr; for( size_t i = 0; ( nullptr != phWaitEvents ) && ( i < numWaitEvents ); ++i ) phWaitEventsLocal[ i ] = reinterpret_cast( phWaitEvents[ i ] )->handle; @@ -2398,8 +2398,8 @@ namespace loader // convert loader handle to driver handle hSignalEvent = ( hSignalEvent ) ? reinterpret_cast( hSignalEvent )->handle : nullptr; - // convert loader handles to driver handles - auto phWaitEventsLocal = new ze_event_handle_t [numWaitEvents]; + // convert loader handles to driver handles, preserving a null input array + auto phWaitEventsLocal = ( phWaitEvents ) ? new ze_event_handle_t [numWaitEvents] : nullptr; for( size_t i = 0; ( nullptr != phWaitEvents ) && ( i < numWaitEvents ); ++i ) phWaitEventsLocal[ i ] = reinterpret_cast( phWaitEvents[ i ] )->handle; @@ -2440,8 +2440,8 @@ namespace loader // convert loader handle to driver handle hSignalEvent = ( hSignalEvent ) ? reinterpret_cast( hSignalEvent )->handle : nullptr; - // convert loader handles to driver handles - auto phWaitEventsLocal = new ze_event_handle_t [numWaitEvents]; + // convert loader handles to driver handles, preserving a null input array + auto phWaitEventsLocal = ( phWaitEvents ) ? new ze_event_handle_t [numWaitEvents] : nullptr; for( size_t i = 0; ( nullptr != phWaitEvents ) && ( i < numWaitEvents ); ++i ) phWaitEventsLocal[ i ] = reinterpret_cast( phWaitEvents[ i ] )->handle; @@ -2482,8 +2482,8 @@ namespace loader // convert loader handle to driver handle hSignalEvent = ( hSignalEvent ) ? reinterpret_cast( hSignalEvent )->handle : nullptr; - // convert loader handles to driver handles - auto phWaitEventsLocal = new ze_event_handle_t [numWaitEvents]; + // convert loader handles to driver handles, preserving a null input array + auto phWaitEventsLocal = ( phWaitEvents ) ? new ze_event_handle_t [numWaitEvents] : nullptr; for( size_t i = 0; ( nullptr != phWaitEvents ) && ( i < numWaitEvents ); ++i ) phWaitEventsLocal[ i ] = reinterpret_cast( phWaitEvents[ i ] )->handle; @@ -2525,8 +2525,8 @@ namespace loader // convert loader handle to driver handle hSignalEvent = ( hSignalEvent ) ? reinterpret_cast( hSignalEvent )->handle : nullptr; - // convert loader handles to driver handles - auto phWaitEventsLocal = new ze_event_handle_t [numWaitEvents]; + // convert loader handles to driver handles, preserving a null input array + auto phWaitEventsLocal = ( phWaitEvents ) ? new ze_event_handle_t [numWaitEvents] : nullptr; for( size_t i = 0; ( nullptr != phWaitEvents ) && ( i < numWaitEvents ); ++i ) phWaitEventsLocal[ i ] = reinterpret_cast( phWaitEvents[ i ] )->handle; @@ -2575,8 +2575,8 @@ namespace loader // convert loader handle to driver handle hSignalEvent = ( hSignalEvent ) ? reinterpret_cast( hSignalEvent )->handle : nullptr; - // convert loader handles to driver handles - auto phWaitEventsLocal = new ze_event_handle_t [numWaitEvents]; + // convert loader handles to driver handles, preserving a null input array + auto phWaitEventsLocal = ( phWaitEvents ) ? new ze_event_handle_t [numWaitEvents] : nullptr; for( size_t i = 0; ( nullptr != phWaitEvents ) && ( i < numWaitEvents ); ++i ) phWaitEventsLocal[ i ] = reinterpret_cast( phWaitEvents[ i ] )->handle; @@ -2620,8 +2620,8 @@ namespace loader // convert loader handle to driver handle hSignalEvent = ( hSignalEvent ) ? reinterpret_cast( hSignalEvent )->handle : nullptr; - // convert loader handles to driver handles - auto phWaitEventsLocal = new ze_event_handle_t [numWaitEvents]; + // convert loader handles to driver handles, preserving a null input array + auto phWaitEventsLocal = ( phWaitEvents ) ? new ze_event_handle_t [numWaitEvents] : nullptr; for( size_t i = 0; ( nullptr != phWaitEvents ) && ( i < numWaitEvents ); ++i ) phWaitEventsLocal[ i ] = reinterpret_cast( phWaitEvents[ i ] )->handle; @@ -2666,8 +2666,8 @@ namespace loader // convert loader handle to driver handle hSignalEvent = ( hSignalEvent ) ? reinterpret_cast( hSignalEvent )->handle : nullptr; - // convert loader handles to driver handles - auto phWaitEventsLocal = new ze_event_handle_t [numWaitEvents]; + // convert loader handles to driver handles, preserving a null input array + auto phWaitEventsLocal = ( phWaitEvents ) ? new ze_event_handle_t [numWaitEvents] : nullptr; for( size_t i = 0; ( nullptr != phWaitEvents ) && ( i < numWaitEvents ); ++i ) phWaitEventsLocal[ i ] = reinterpret_cast( phWaitEvents[ i ] )->handle; @@ -2714,8 +2714,8 @@ namespace loader // convert loader handle to driver handle hSignalEvent = ( hSignalEvent ) ? reinterpret_cast( hSignalEvent )->handle : nullptr; - // convert loader handles to driver handles - auto phWaitEventsLocal = new ze_event_handle_t [numWaitEvents]; + // convert loader handles to driver handles, preserving a null input array + auto phWaitEventsLocal = ( phWaitEvents ) ? new ze_event_handle_t [numWaitEvents] : nullptr; for( size_t i = 0; ( nullptr != phWaitEvents ) && ( i < numWaitEvents ); ++i ) phWaitEventsLocal[ i ] = reinterpret_cast( phWaitEvents[ i ] )->handle; @@ -2758,8 +2758,8 @@ namespace loader // convert loader handle to driver handle hSignalEvent = ( hSignalEvent ) ? reinterpret_cast( hSignalEvent )->handle : nullptr; - // convert loader handles to driver handles - auto phWaitEventsLocal = new ze_event_handle_t [numWaitEvents]; + // convert loader handles to driver handles, preserving a null input array + auto phWaitEventsLocal = ( phWaitEvents ) ? new ze_event_handle_t [numWaitEvents] : nullptr; for( size_t i = 0; ( nullptr != phWaitEvents ) && ( i < numWaitEvents ); ++i ) phWaitEventsLocal[ i ] = reinterpret_cast( phWaitEvents[ i ] )->handle; @@ -2802,8 +2802,8 @@ namespace loader // convert loader handle to driver handle hSignalEvent = ( hSignalEvent ) ? reinterpret_cast( hSignalEvent )->handle : nullptr; - // convert loader handles to driver handles - auto phWaitEventsLocal = new ze_event_handle_t [numWaitEvents]; + // convert loader handles to driver handles, preserving a null input array + auto phWaitEventsLocal = ( phWaitEvents ) ? new ze_event_handle_t [numWaitEvents] : nullptr; for( size_t i = 0; ( nullptr != phWaitEvents ) && ( i < numWaitEvents ); ++i ) phWaitEventsLocal[ i ] = reinterpret_cast( phWaitEvents[ i ] )->handle; @@ -2897,8 +2897,8 @@ namespace loader // convert loader handle to driver handle hContext = reinterpret_cast( hContext )->handle; - // convert loader handles to driver handles - auto phDevicesLocal = new ze_device_handle_t [numDevices]; + // convert loader handles to driver handles, preserving a null input array + auto phDevicesLocal = ( phDevices ) ? new ze_device_handle_t [numDevices] : nullptr; for( size_t i = 0; ( nullptr != phDevices ) && ( i < numDevices ); ++i ) phDevicesLocal[ i ] = reinterpret_cast( phDevices[ i ] )->handle; @@ -3360,8 +3360,8 @@ namespace loader // convert loader handle to driver handle hCommandList = reinterpret_cast( hCommandList )->handle; - // convert loader handles to driver handles - auto phEventsLocal = new ze_event_handle_t [numEvents]; + // convert loader handles to driver handles, preserving a null input array + auto phEventsLocal = ( phEvents ) ? new ze_event_handle_t [numEvents] : nullptr; for( size_t i = 0; ( nullptr != phEvents ) && ( i < numEvents ); ++i ) phEventsLocal[ i ] = reinterpret_cast( phEvents[ i ] )->handle; @@ -3558,16 +3558,16 @@ namespace loader // convert loader handle to driver handle hCommandList = reinterpret_cast( hCommandList )->handle; - // convert loader handles to driver handles - auto phEventsLocal = new ze_event_handle_t [numEvents]; + // convert loader handles to driver handles, preserving a null input array + auto phEventsLocal = ( phEvents ) ? new ze_event_handle_t [numEvents] : nullptr; for( size_t i = 0; ( nullptr != phEvents ) && ( i < numEvents ); ++i ) phEventsLocal[ i ] = reinterpret_cast( phEvents[ i ] )->handle; // convert loader handle to driver handle hSignalEvent = ( hSignalEvent ) ? reinterpret_cast( hSignalEvent )->handle : nullptr; - // convert loader handles to driver handles - auto phWaitEventsLocal = new ze_event_handle_t [numWaitEvents]; + // convert loader handles to driver handles, preserving a null input array + auto phWaitEventsLocal = ( phWaitEvents ) ? new ze_event_handle_t [numWaitEvents] : nullptr; for( size_t i = 0; ( nullptr != phWaitEvents ) && ( i < numWaitEvents ); ++i ) phWaitEventsLocal[ i ] = reinterpret_cast( phWaitEvents[ i ] )->handle; @@ -4544,8 +4544,8 @@ namespace loader if( nullptr == pfnDynamicLink ) return ZE_RESULT_ERROR_UNINITIALIZED; - // convert loader handles to driver handles - auto phModulesLocal = new ze_module_handle_t [numModules]; + // convert loader handles to driver handles, preserving a null input array + auto phModulesLocal = ( phModules ) ? new ze_module_handle_t [numModules] : nullptr; for( size_t i = 0; ( nullptr != phModules ) && ( i < numModules ); ++i ) phModulesLocal[ i ] = reinterpret_cast( phModules[ i ] )->handle; @@ -5155,8 +5155,8 @@ namespace loader // convert loader handle to driver handle hSignalEvent = ( hSignalEvent ) ? reinterpret_cast( hSignalEvent )->handle : nullptr; - // convert loader handles to driver handles - auto phWaitEventsLocal = new ze_event_handle_t [numWaitEvents]; + // convert loader handles to driver handles, preserving a null input array + auto phWaitEventsLocal = ( phWaitEvents ) ? new ze_event_handle_t [numWaitEvents] : nullptr; for( size_t i = 0; ( nullptr != phWaitEvents ) && ( i < numWaitEvents ); ++i ) phWaitEventsLocal[ i ] = reinterpret_cast( phWaitEvents[ i ] )->handle; @@ -5199,8 +5199,8 @@ namespace loader // convert loader handle to driver handle hSignalEvent = ( hSignalEvent ) ? reinterpret_cast( hSignalEvent )->handle : nullptr; - // convert loader handles to driver handles - auto phWaitEventsLocal = new ze_event_handle_t [numWaitEvents]; + // convert loader handles to driver handles, preserving a null input array + auto phWaitEventsLocal = ( phWaitEvents ) ? new ze_event_handle_t [numWaitEvents] : nullptr; for( size_t i = 0; ( nullptr != phWaitEvents ) && ( i < numWaitEvents ); ++i ) phWaitEventsLocal[ i ] = reinterpret_cast( phWaitEvents[ i ] )->handle; @@ -5245,8 +5245,8 @@ namespace loader // convert loader handle to driver handle hSignalEvent = ( hSignalEvent ) ? reinterpret_cast( hSignalEvent )->handle : nullptr; - // convert loader handles to driver handles - auto phWaitEventsLocal = new ze_event_handle_t [numWaitEvents]; + // convert loader handles to driver handles, preserving a null input array + auto phWaitEventsLocal = ( phWaitEvents ) ? new ze_event_handle_t [numWaitEvents] : nullptr; for( size_t i = 0; ( nullptr != phWaitEvents ) && ( i < numWaitEvents ); ++i ) phWaitEventsLocal[ i ] = reinterpret_cast( phWaitEvents[ i ] )->handle; @@ -5288,8 +5288,8 @@ namespace loader // convert loader handle to driver handle hSignalEvent = ( hSignalEvent ) ? reinterpret_cast( hSignalEvent )->handle : nullptr; - // convert loader handles to driver handles - auto phWaitEventsLocal = new ze_event_handle_t [numWaitEvents]; + // convert loader handles to driver handles, preserving a null input array + auto phWaitEventsLocal = ( phWaitEvents ) ? new ze_event_handle_t [numWaitEvents] : nullptr; for( size_t i = 0; ( nullptr != phWaitEvents ) && ( i < numWaitEvents ); ++i ) phWaitEventsLocal[ i ] = reinterpret_cast( phWaitEvents[ i ] )->handle; @@ -5332,8 +5332,8 @@ namespace loader // convert loader handle to driver handle hSignalEvent = ( hSignalEvent ) ? reinterpret_cast( hSignalEvent )->handle : nullptr; - // convert loader handles to driver handles - auto phWaitEventsLocal = new ze_event_handle_t [numWaitEvents]; + // convert loader handles to driver handles, preserving a null input array + auto phWaitEventsLocal = ( phWaitEvents ) ? new ze_event_handle_t [numWaitEvents] : nullptr; for( size_t i = 0; ( nullptr != phWaitEvents ) && ( i < numWaitEvents ); ++i ) phWaitEventsLocal[ i ] = reinterpret_cast( phWaitEvents[ i ] )->handle; @@ -5374,16 +5374,16 @@ namespace loader // convert loader handle to driver handle hCommandList = reinterpret_cast( hCommandList )->handle; - // convert loader handles to driver handles - auto phKernelsLocal = new ze_kernel_handle_t [numKernels]; + // convert loader handles to driver handles, preserving a null input array + auto phKernelsLocal = ( phKernels ) ? new ze_kernel_handle_t [numKernels] : nullptr; for( size_t i = 0; ( nullptr != phKernels ) && ( i < numKernels ); ++i ) phKernelsLocal[ i ] = reinterpret_cast( phKernels[ i ] )->handle; // convert loader handle to driver handle hSignalEvent = ( hSignalEvent ) ? reinterpret_cast( hSignalEvent )->handle : nullptr; - // convert loader handles to driver handles - auto phWaitEventsLocal = new ze_event_handle_t [numWaitEvents]; + // convert loader handles to driver handles, preserving a null input array + auto phWaitEventsLocal = ( phWaitEvents ) ? new ze_event_handle_t [numWaitEvents] : nullptr; for( size_t i = 0; ( nullptr != phWaitEvents ) && ( i < numWaitEvents ); ++i ) phWaitEventsLocal[ i ] = reinterpret_cast( phWaitEvents[ i ] )->handle; @@ -6247,8 +6247,8 @@ namespace loader // convert loader handle to driver handle hSignalEvent = ( hSignalEvent ) ? reinterpret_cast( hSignalEvent )->handle : nullptr; - // convert loader handles to driver handles - auto phWaitEventsLocal = new ze_event_handle_t [numWaitEvents]; + // convert loader handles to driver handles, preserving a null input array + auto phWaitEventsLocal = ( phWaitEvents ) ? new ze_event_handle_t [numWaitEvents] : nullptr; for( size_t i = 0; ( nullptr != phWaitEvents ) && ( i < numWaitEvents ); ++i ) phWaitEventsLocal[ i ] = reinterpret_cast( phWaitEvents[ i ] )->handle; @@ -6295,8 +6295,8 @@ namespace loader // convert loader handle to driver handle hSignalEvent = ( hSignalEvent ) ? reinterpret_cast( hSignalEvent )->handle : nullptr; - // convert loader handles to driver handles - auto phWaitEventsLocal = new ze_event_handle_t [numWaitEvents]; + // convert loader handles to driver handles, preserving a null input array + auto phWaitEventsLocal = ( phWaitEvents ) ? new ze_event_handle_t [numWaitEvents] : nullptr; for( size_t i = 0; ( nullptr != phWaitEvents ) && ( i < numWaitEvents ); ++i ) phWaitEventsLocal[ i ] = reinterpret_cast( phWaitEvents[ i ] )->handle; @@ -6356,8 +6356,8 @@ namespace loader if( nullptr == pfnInspectLinkageExt ) return ZE_RESULT_ERROR_UNINITIALIZED; - // convert loader handles to driver handles - auto phModulesLocal = new ze_module_handle_t [numModules]; + // convert loader handles to driver handles, preserving a null input array + auto phModulesLocal = ( phModules ) ? new ze_module_handle_t [numModules] : nullptr; for( size_t i = 0; ( nullptr != phModules ) && ( i < numModules ); ++i ) phModulesLocal[ i ] = reinterpret_cast( phModules[ i ] )->handle; @@ -7182,16 +7182,16 @@ namespace loader // convert loader handle to driver handle hCommandListImmediate = reinterpret_cast( hCommandListImmediate )->handle; - // convert loader handles to driver handles - auto phCommandListsLocal = new ze_command_list_handle_t [numCommandLists]; + // convert loader handles to driver handles, preserving a null input array + auto phCommandListsLocal = ( phCommandLists ) ? new ze_command_list_handle_t [numCommandLists] : nullptr; for( size_t i = 0; ( nullptr != phCommandLists ) && ( i < numCommandLists ); ++i ) phCommandListsLocal[ i ] = reinterpret_cast( phCommandLists[ i ] )->handle; // convert loader handle to driver handle hSignalEvent = ( hSignalEvent ) ? reinterpret_cast( hSignalEvent )->handle : nullptr; - // convert loader handles to driver handles - auto phWaitEventsLocal = new ze_event_handle_t [numWaitEvents]; + // convert loader handles to driver handles, preserving a null input array + auto phWaitEventsLocal = ( phWaitEvents ) ? new ze_event_handle_t [numWaitEvents] : nullptr; for( size_t i = 0; ( nullptr != phWaitEvents ) && ( i < numWaitEvents ); ++i ) phWaitEventsLocal[ i ] = reinterpret_cast( phWaitEvents[ i ] )->handle; @@ -7233,16 +7233,16 @@ namespace loader // convert loader handle to driver handle hCommandListImmediate = reinterpret_cast( hCommandListImmediate )->handle; - // convert loader handles to driver handles - auto phCommandListsLocal = new ze_command_list_handle_t [numCommandLists]; + // convert loader handles to driver handles, preserving a null input array + auto phCommandListsLocal = ( phCommandLists ) ? new ze_command_list_handle_t [numCommandLists] : nullptr; for( size_t i = 0; ( nullptr != phCommandLists ) && ( i < numCommandLists ); ++i ) phCommandListsLocal[ i ] = reinterpret_cast( phCommandLists[ i ] )->handle; // convert loader handle to driver handle hSignalEvent = ( hSignalEvent ) ? reinterpret_cast( hSignalEvent )->handle : nullptr; - // convert loader handles to driver handles - auto phWaitEventsLocal = new ze_event_handle_t [numWaitEvents]; + // convert loader handles to driver handles, preserving a null input array + auto phWaitEventsLocal = ( phWaitEvents ) ? new ze_event_handle_t [numWaitEvents] : nullptr; for( size_t i = 0; ( nullptr != phWaitEvents ) && ( i < numWaitEvents ); ++i ) phWaitEventsLocal[ i ] = reinterpret_cast( phWaitEvents[ i ] )->handle; @@ -7304,8 +7304,8 @@ namespace loader // convert loader handle to driver handle hCommandList = reinterpret_cast( hCommandList )->handle; - // convert loader handles to driver handles - auto phKernelsLocal = new ze_kernel_handle_t [numKernels]; + // convert loader handles to driver handles, preserving a null input array + auto phKernelsLocal = ( phKernels ) ? new ze_kernel_handle_t [numKernels] : nullptr; for( size_t i = 0; ( nullptr != phKernels ) && ( i < numKernels ); ++i ) phKernelsLocal[ i ] = reinterpret_cast( phKernels[ i ] )->handle; @@ -7419,8 +7419,8 @@ namespace loader // convert loader handle to driver handle hCommandList = reinterpret_cast( hCommandList )->handle; - // convert loader handles to driver handles - auto phWaitEventsLocal = new ze_event_handle_t [numWaitEvents]; + // convert loader handles to driver handles, preserving a null input array + auto phWaitEventsLocal = ( phWaitEvents ) ? new ze_event_handle_t [numWaitEvents] : nullptr; for( size_t i = 0; ( nullptr != phWaitEvents ) && ( i < numWaitEvents ); ++i ) phWaitEventsLocal[ i ] = reinterpret_cast( phWaitEvents[ i ] )->handle; @@ -7453,8 +7453,8 @@ namespace loader // convert loader handle to driver handle hCommandList = reinterpret_cast( hCommandList )->handle; - // convert loader handles to driver handles - auto phKernelsLocal = new ze_kernel_handle_t [numKernels]; + // convert loader handles to driver handles, preserving a null input array + auto phKernelsLocal = ( phKernels ) ? new ze_kernel_handle_t [numKernels] : nullptr; for( size_t i = 0; ( nullptr != phKernels ) && ( i < numKernels ); ++i ) phKernelsLocal[ i ] = reinterpret_cast( phKernels[ i ] )->handle; @@ -7583,16 +7583,16 @@ namespace loader // convert loader handle to driver handle hCommandList = reinterpret_cast( hCommandList )->handle; - // convert loader handles to driver handles - auto phSemaphoresLocal = new ze_external_semaphore_ext_handle_t [numSemaphores]; + // convert loader handles to driver handles, preserving a null input array + auto phSemaphoresLocal = ( phSemaphores ) ? new ze_external_semaphore_ext_handle_t [numSemaphores] : nullptr; for( size_t i = 0; ( nullptr != phSemaphores ) && ( i < numSemaphores ); ++i ) phSemaphoresLocal[ i ] = reinterpret_cast( phSemaphores[ i ] )->handle; // convert loader handle to driver handle hSignalEvent = ( hSignalEvent ) ? reinterpret_cast( hSignalEvent )->handle : nullptr; - // convert loader handles to driver handles - auto phWaitEventsLocal = new ze_event_handle_t [numWaitEvents]; + // convert loader handles to driver handles, preserving a null input array + auto phWaitEventsLocal = ( phWaitEvents ) ? new ze_event_handle_t [numWaitEvents] : nullptr; for( size_t i = 0; ( nullptr != phWaitEvents ) && ( i < numWaitEvents ); ++i ) phWaitEventsLocal[ i ] = reinterpret_cast( phWaitEvents[ i ] )->handle; @@ -7632,16 +7632,16 @@ namespace loader // convert loader handle to driver handle hCommandList = reinterpret_cast( hCommandList )->handle; - // convert loader handles to driver handles - auto phSemaphoresLocal = new ze_external_semaphore_ext_handle_t [numSemaphores]; + // convert loader handles to driver handles, preserving a null input array + auto phSemaphoresLocal = ( phSemaphores ) ? new ze_external_semaphore_ext_handle_t [numSemaphores] : nullptr; for( size_t i = 0; ( nullptr != phSemaphores ) && ( i < numSemaphores ); ++i ) phSemaphoresLocal[ i ] = reinterpret_cast( phSemaphores[ i ] )->handle; // convert loader handle to driver handle hSignalEvent = ( hSignalEvent ) ? reinterpret_cast( hSignalEvent )->handle : nullptr; - // convert loader handles to driver handles - auto phWaitEventsLocal = new ze_event_handle_t [numWaitEvents]; + // convert loader handles to driver handles, preserving a null input array + auto phWaitEventsLocal = ( phWaitEvents ) ? new ze_event_handle_t [numWaitEvents] : nullptr; for( size_t i = 0; ( nullptr != phWaitEvents ) && ( i < numWaitEvents ); ++i ) phWaitEventsLocal[ i ] = reinterpret_cast( phWaitEvents[ i ] )->handle; @@ -7815,8 +7815,8 @@ namespace loader // convert loader handle to driver handle hSignalEvent = ( hSignalEvent ) ? reinterpret_cast( hSignalEvent )->handle : nullptr; - // convert loader handles to driver handles - auto phWaitEventsLocal = new ze_event_handle_t [numWaitEvents]; + // convert loader handles to driver handles, preserving a null input array + auto phWaitEventsLocal = ( phWaitEvents ) ? new ze_event_handle_t [numWaitEvents] : nullptr; for( size_t i = 0; ( nullptr != phWaitEvents ) && ( i < numWaitEvents ); ++i ) phWaitEventsLocal[ i ] = reinterpret_cast( phWaitEvents[ i ] )->handle; @@ -8411,8 +8411,8 @@ namespace loader // convert loader handle to driver handle hSignalEvent = ( hSignalEvent ) ? reinterpret_cast( hSignalEvent )->handle : nullptr; - // convert loader handles to driver handles - auto phWaitEventsLocal = new ze_event_handle_t [numWaitEvents]; + // convert loader handles to driver handles, preserving a null input array + auto phWaitEventsLocal = ( phWaitEvents ) ? new ze_event_handle_t [numWaitEvents] : nullptr; for( size_t i = 0; ( nullptr != phWaitEvents ) && ( i < numWaitEvents ); ++i ) phWaitEventsLocal[ i ] = reinterpret_cast( phWaitEvents[ i ] )->handle; @@ -8604,8 +8604,8 @@ namespace loader // convert loader handle to driver handle hSignalEvent = ( hSignalEvent ) ? reinterpret_cast( hSignalEvent )->handle : nullptr; - // convert loader handles to driver handles - auto phWaitEventsLocal = new ze_event_handle_t [numWaitEvents]; + // convert loader handles to driver handles, preserving a null input array + auto phWaitEventsLocal = ( phWaitEvents ) ? new ze_event_handle_t [numWaitEvents] : nullptr; for( size_t i = 0; ( nullptr != phWaitEvents ) && ( i < numWaitEvents ); ++i ) phWaitEventsLocal[ i ] = reinterpret_cast( phWaitEvents[ i ] )->handle; diff --git a/source/loader/zes_ldrddi.cpp b/source/loader/zes_ldrddi.cpp index dee1817a..1217a8de 100644 --- a/source/loader/zes_ldrddi.cpp +++ b/source/loader/zes_ldrddi.cpp @@ -1427,8 +1427,8 @@ namespace loader // convert loader handle to driver handle hDriver = reinterpret_cast( hDriver )->handle; - // convert loader handles to driver handles - auto phDevicesLocal = new zes_device_handle_t [count]; + // convert loader handles to driver handles, preserving a null input array + auto phDevicesLocal = ( phDevices ) ? new zes_device_handle_t [count] : nullptr; for( size_t i = 0; ( nullptr != phDevices ) && ( i < count ); ++i ) phDevicesLocal[ i ] = reinterpret_cast( phDevices[ i ] )->handle; @@ -1474,8 +1474,8 @@ namespace loader // convert loader handle to driver handle hDriver = reinterpret_cast( hDriver )->handle; - // convert loader handles to driver handles - auto phDevicesLocal = new zes_device_handle_t [count]; + // convert loader handles to driver handles, preserving a null input array + auto phDevicesLocal = ( phDevices ) ? new zes_device_handle_t [count] : nullptr; for( size_t i = 0; ( nullptr != phDevices ) && ( i < count ); ++i ) phDevicesLocal[ i ] = reinterpret_cast( phDevices[ i ] )->handle; @@ -1735,8 +1735,8 @@ namespace loader // convert loader handle to driver handle hDevice = reinterpret_cast( hDevice )->handle; - // convert loader handles to driver handles - auto phPortLocal = new zes_fabric_port_handle_t [numPorts]; + // convert loader handles to driver handles, preserving a null input array + auto phPortLocal = ( phPort ) ? new zes_fabric_port_handle_t [numPorts] : nullptr; for( size_t i = 0; ( nullptr != phPort ) && ( i < numPorts ); ++i ) phPortLocal[ i ] = reinterpret_cast( phPort[ i ] )->handle; diff --git a/source/loader/zet_ldrddi.cpp b/source/loader/zet_ldrddi.cpp index 541aa001..a2fbf09b 100644 --- a/source/loader/zet_ldrddi.cpp +++ b/source/loader/zet_ldrddi.cpp @@ -738,8 +738,8 @@ namespace loader // convert loader handle to driver handle hDevice = reinterpret_cast( hDevice )->handle; - // convert loader handles to driver handles - auto phMetricGroupsLocal = new zet_metric_group_handle_t [count]; + // convert loader handles to driver handles, preserving a null input array + auto phMetricGroupsLocal = ( phMetricGroups ) ? new zet_metric_group_handle_t [count] : nullptr; for( size_t i = 0; ( nullptr != phMetricGroups ) && ( i < count ); ++i ) phMetricGroupsLocal[ i ] = reinterpret_cast( phMetricGroups[ i ] )->handle; @@ -1128,8 +1128,8 @@ namespace loader // convert loader handle to driver handle hSignalEvent = ( hSignalEvent ) ? reinterpret_cast( hSignalEvent )->handle : nullptr; - // convert loader handles to driver handles - auto phWaitEventsLocal = new ze_event_handle_t [numWaitEvents]; + // convert loader handles to driver handles, preserving a null input array + auto phWaitEventsLocal = ( phWaitEvents ) ? new ze_event_handle_t [numWaitEvents] : nullptr; for( size_t i = 0; ( nullptr != phWaitEvents ) && ( i < numWaitEvents ); ++i ) phWaitEventsLocal[ i ] = reinterpret_cast( phWaitEvents[ i ] )->handle; @@ -2069,8 +2069,8 @@ namespace loader // convert loader handle to driver handle hDevice = reinterpret_cast( hDevice )->handle; - // convert loader handles to driver handles - auto phMetricGroupsLocal = new zet_metric_group_handle_t [metricGroupCount ]; + // convert loader handles to driver handles, preserving a null input array + auto phMetricGroupsLocal = ( phMetricGroups ) ? new zet_metric_group_handle_t [metricGroupCount ] : nullptr; for( size_t i = 0; ( nullptr != phMetricGroups ) && ( i < metricGroupCount ); ++i ) phMetricGroupsLocal[ i ] = reinterpret_cast( phMetricGroups[ i ] )->handle; @@ -2384,8 +2384,8 @@ namespace loader // convert loader handle to driver handle phMetricDecoder = reinterpret_cast( phMetricDecoder )->handle; - // convert loader handles to driver handles - auto phMetricsLocal = new zet_metric_handle_t [metricsCount]; + // convert loader handles to driver handles, preserving a null input array + auto phMetricsLocal = ( phMetrics ) ? new zet_metric_handle_t [metricsCount] : nullptr; for( size_t i = 0; ( nullptr != phMetrics ) && ( i < metricsCount ); ++i ) phMetricsLocal[ i ] = reinterpret_cast( phMetrics[ i ] )->handle;