diff options
author | Jason Ekstrand <jason.ekstrand@intel.com> | 2016-10-27 01:33:39 -0700 |
---|---|---|
committer | Jason Ekstrand <jason.ekstrand@intel.com> | 2016-11-17 12:03:24 -0800 |
commit | 9b9fb6d212147d4d240285b70fd7346d1326d212 (patch) | |
tree | 383d99734dba0022528293bf0a966001ada701b6 /src | |
parent | a512565b2b9f991729d747a7fefc1f89d68894d2 (diff) |
util/vk_alloc: Add a vk_zalloc2 helper
Reviewed-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/util/vk_alloc.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/util/vk_alloc.h b/src/util/vk_alloc.h index 7ae5c9dfe4..2915021826 100644 --- a/src/util/vk_alloc.h +++ b/src/util/vk_alloc.h @@ -25,6 +25,7 @@ /* common allocation inlines for vulkan drivers */ +#include <string.h> #include <vulkan/vulkan.h> static inline void * @@ -64,6 +65,21 @@ vk_alloc2(const VkAllocationCallbacks *parent_alloc, return vk_alloc(parent_alloc, size, align, scope); } +static inline void * +vk_zalloc2(const VkAllocationCallbacks *parent_alloc, + const VkAllocationCallbacks *alloc, + size_t size, size_t align, + VkSystemAllocationScope scope) +{ + void *mem = vk_alloc2(parent_alloc, alloc, size, align, scope); + if (mem == NULL) + return NULL; + + memset(mem, 0, size); + + return mem; +} + static inline void vk_free2(const VkAllocationCallbacks *parent_alloc, const VkAllocationCallbacks *alloc, |