diff options
author | Jason Ekstrand <[email protected]> | 2018-01-29 18:11:38 -0800 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2018-08-28 13:05:54 -0500 |
commit | 4ffb575da59fd3aece02734ca4fd3212d5002d55 (patch) | |
tree | b1fd1b056c05eeef335026395db5cd7ec11cf872 /src/vulkan | |
parent | 7c00db9527245d80cb748ec3442163585a5463a6 (diff) |
vulkan/alloc: Add a vk_strdup helper
Cc: "18.2" <[email protected]>
Reviewed-by: Lionel Landwerlin <[email protected]>
Diffstat (limited to 'src/vulkan')
-rw-r--r-- | src/vulkan/util/vk_alloc.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/vulkan/util/vk_alloc.h b/src/vulkan/util/vk_alloc.h index f58a80625a8..2e807a96d9e 100644 --- a/src/vulkan/util/vk_alloc.h +++ b/src/vulkan/util/vk_alloc.h @@ -67,6 +67,23 @@ vk_free(const VkAllocationCallbacks *alloc, void *data) alloc->pfnFree(alloc->pUserData, data); } +static inline char * +vk_strdup(const VkAllocationCallbacks *alloc, const char *s, + VkSystemAllocationScope scope) +{ + if (s == NULL) + return NULL; + + size_t size = strlen(s) + 1; + char *copy = vk_alloc(alloc, size, 1, scope); + if (copy == NULL) + return NULL; + + memcpy(copy, s, size); + + return copy; +} + static inline void * vk_alloc2(const VkAllocationCallbacks *parent_alloc, const VkAllocationCallbacks *alloc, |