mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-09 04:00:12 +01:00
vulkan/alloc: Add a vk_strdup helper
Cc: "18.2" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
(cherry picked from commit 4ffb575da5)
This commit is contained in:
parent
3d52cfe80b
commit
70e7336e66
1 changed files with 17 additions and 0 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue