From: Jason Ekstrand Date: Tue, 8 Aug 2017 19:25:26 +0000 (-0700) Subject: vulkan/util: Add a vk_zalloc helper X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ae8365a9eb017161c294f2a9171d0cbfd7249e20;p=mesa.git vulkan/util: Add a vk_zalloc helper Reviewed-by: Lionel Landwerlin --- 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,