@@ -50,16 +50,14 @@ namespace nvofapi {
5050uint32_t NvOFInstance::GetVkOFAQueue () {
5151uint32_t count =0 ;
5252m_vkGetPhysicalDeviceQueueFamilyProperties (m_vkPhysicalDevice, &count,nullptr );
53- VkQueueFamilyProperties* queueFamProps =( VkQueueFamilyProperties*) calloc ( sizeof (VkQueueFamilyProperties), count);
54- m_vkGetPhysicalDeviceQueueFamilyProperties (m_vkPhysicalDevice, &count, queueFamProps);
53+ auto queueFamProps =std::vector< VkQueueFamilyProperties>( count);
54+ m_vkGetPhysicalDeviceQueueFamilyProperties (m_vkPhysicalDevice, &count, queueFamProps. data () );
5555
5656for (uint32_t i =0 ; i < count; i++) {
5757if (queueFamProps[i].queueFlags & VK_QUEUE_OPTICAL_FLOW_BIT_NV) {
58- free (queueFamProps);
5958return i;
6059 }
6160 }
62- free (queueFamProps);
6361return -1 ;
6462 }
6563
@@ -193,29 +191,23 @@ namespace nvofapi {
193191 }
194192 }
195193 }
196- VkRect2D* regions =nullptr ;
197-
198- if (inParams->numRois ) {
199- regions = (VkRect2D*)calloc (sizeof (VkRect2D), inParams->numRois );
200- for (uint32_t i =0 ; i < inParams->numRois ; i++) {
201- regions[i].offset .x = inParams->roiData [i].start_x ;
202- regions[i].offset .y = inParams->roiData [i].start_y ;
203- regions[i].extent .width = inParams->roiData [i].width ;
204- regions[i].extent .height = inParams->roiData [i].height ;
205- }
194+ auto regions = std::vector<VkRect2D>(inParams->numRois );
195+ for (uint32_t i =0 ; i < inParams->numRois ; i++) {
196+ regions[i].offset .x = inParams->roiData [i].start_x ;
197+ regions[i].offset .y = inParams->roiData [i].start_y ;
198+ regions[i].extent .width = inParams->roiData [i].width ;
199+ regions[i].extent .height = inParams->roiData [i].height ;
206200 }
207201
208202 VkOpticalFlowExecuteInfoNV ofaExecuteInfo{};
209203 ofaExecuteInfo.sType = VK_STRUCTURE_TYPE_OPTICAL_FLOW_EXECUTE_INFO_NV;
210204 ofaExecuteInfo.regionCount = inParams->numRois ;
211- ofaExecuteInfo.pRegions = regions;
205+ ofaExecuteInfo.pRegions = regions. data () ;
212206
213207if (inParams->disableTemporalHints ) {
214208 ofaExecuteInfo.flags |= VK_OPTICAL_FLOW_EXECUTE_DISABLE_TEMPORAL_HINTS_BIT_NV;
215209 }
216210
217211m_vkCmdOpticalFlowExecuteNV (cmdBuf, m_vkOfaSession, &ofaExecuteInfo);
218-
219- free (regions);
220212 }
221213}