From ae8365a9eb017161c294f2a9171d0cbfd7249e20 Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Tue, 8 Aug 2017 12:25:26 -0700 Subject: [PATCH] vulkan/util: Add a vk_zalloc helper Reviewed-by: Lionel Landwerlin --- src/vulkan/util/vk_alloc.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/vulkan/util/vk_alloc.h b/src/vulkan/util/vk_alloc.h index 29150218269..f58a80625a8 100644 --- a/src/vulkan/util/vk_alloc.h +++ b/src/vulkan/util/vk_alloc.h @@ -36,6 +36,20 @@ vk_alloc(const VkAllocationCallbacks *alloc, return alloc->pfnAllocation(alloc->pUserData, size, align, scope); } +static inline void * +vk_zalloc(const VkAllocationCallbacks *alloc, + size_t size, size_t align, + VkSystemAllocationScope scope) +{ + void *mem = vk_alloc(alloc, size, align, scope); + if (mem == NULL) + return NULL; + + memset(mem, 0, size); + + return mem; +} + static inline void * vk_realloc(const VkAllocationCallbacks *alloc, void *ptr, size_t size, size_t align, -- 2.30.2