[Mesa-dev] [PATCH v2 05/10] vulkan/util: Add a vk_zalloc helper

Jason Ekstrand jason at jlekstrand.net
Thu Aug 24 23:49:32 UTC 2017


---
 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 2915021..f58a806 100644
--- a/src/vulkan/util/vk_alloc.h
+++ b/src/vulkan/util/vk_alloc.h
@@ -37,6 +37,20 @@ vk_alloc(const VkAllocationCallbacks *alloc,
 }
 
 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,
            VkSystemAllocationScope scope)
-- 
2.5.0.400.gff86faf



More information about the mesa-dev mailing list