From dfa2051cd2155dea0986fb9ee4f6aa9a2128d0d7 Mon Sep 17 00:00:00 2001 From: Adam Sawicki Date: Thu, 28 Oct 2021 16:17:07 +0200 Subject: [PATCH] Improvement in vmaCreateAllocator in case creation fails --- include/vk_mem_alloc.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/include/vk_mem_alloc.h b/include/vk_mem_alloc.h index a9cefa6..d6e0edb 100644 --- a/include/vk_mem_alloc.h +++ b/include/vk_mem_alloc.h @@ -16725,7 +16725,13 @@ VMA_CALL_PRE VkResult VMA_CALL_POST vmaCreateAllocator( (VK_VERSION_MAJOR(pCreateInfo->vulkanApiVersion) == 1 && VK_VERSION_MINOR(pCreateInfo->vulkanApiVersion) <= 2)); VMA_DEBUG_LOG("vmaCreateAllocator"); *pAllocator = vma_new(pCreateInfo->pAllocationCallbacks, VmaAllocator_T)(pCreateInfo); - return (*pAllocator)->Init(pCreateInfo); + VkResult result = (*pAllocator)->Init(pCreateInfo); + if(result < 0) + { + vma_delete(pCreateInfo->pAllocationCallbacks, *pAllocator); + *pAllocator = VK_NULL_HANDLE; + } + return result; } VMA_CALL_PRE void VMA_CALL_POST vmaDestroyAllocator(