vulkan/alloc: Add a vk_strdup helper
Cc: "18.2" <mesa-stable@lists.freedesktop.org> Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user