From: Rémi Bernon rbernon@codeweavers.com
--- dlls/winevulkan/vulkan.c | 35 ++++++++--------------------------- 1 file changed, 8 insertions(+), 27 deletions(-)
diff --git a/dlls/winevulkan/vulkan.c b/dlls/winevulkan/vulkan.c index a2112765008..9631b3a0eab 100644 --- a/dlls/winevulkan/vulkan.c +++ b/dlls/winevulkan/vulkan.c @@ -499,25 +499,6 @@ static VkResult wine_vk_device_convert_create_info(struct wine_phys_dev *phys_de return VK_SUCCESS; }
-/* Helper function used for freeing a device structure. This function supports full - * and partial object cleanups and can thus be used for vkCreateDevice failures. - */ -static void wine_vk_device_free(struct wine_device *device) -{ - if (device->queues) - { - free(device->queues); - device->queues = NULL; - } - - if (device->host_device && device->funcs.p_vkDestroyDevice) - { - device->funcs.p_vkDestroyDevice(device->host_device, NULL /* pAllocator */); - } - - free(device); -} - NTSTATUS init_vulkan(void *args) { vk_funcs = __wine_get_vulkan_driver(WINE_VULKAN_DRIVER_VERSION); @@ -831,7 +812,8 @@ VkResult wine_vkCreateDevice(VkPhysicalDevice phys_dev_handle, const VkDeviceCre if (res != VK_SUCCESS) { WARN("Failed to create device, res=%d.\n", res); - goto fail; + free(object); + return res; }
/* Just load all function pointers we are aware off. The loader takes care of filtering. @@ -854,8 +836,9 @@ VkResult wine_vkCreateDevice(VkPhysicalDevice phys_dev_handle, const VkDeviceCre
if (!(object->queues = calloc(object->queue_count, sizeof(*object->queues)))) { - res = VK_ERROR_OUT_OF_HOST_MEMORY; - goto fail; + object->funcs.p_vkDestroyDevice(object->host_device, NULL /* pAllocator */); + free(object); + return VK_ERROR_OUT_OF_HOST_MEMORY; }
next_queue = object->queues; @@ -885,10 +868,6 @@ VkResult wine_vkCreateDevice(VkPhysicalDevice phys_dev_handle, const VkDeviceCre *ret_device = device_handle; add_handle_mapping_ptr(instance, *ret_device, object->host_device, &object->wrapper_entry); return VK_SUCCESS; - -fail: - wine_vk_device_free(object); - return res; }
VkResult wine_vkCreateInstance(const VkInstanceCreateInfo *create_info, @@ -993,7 +972,9 @@ void wine_vkDestroyDevice(VkDevice handle, const VkAllocationCallbacks *allocato } remove_handle_mapping(device->phys_dev->instance, &device->wrapper_entry);
- wine_vk_device_free(device); + device->funcs.p_vkDestroyDevice(device->host_device, NULL /* pAllocator */); + free(device->queues); + free(device); }
void wine_vkDestroyInstance(VkInstance handle, const VkAllocationCallbacks *allocator)