util/ralloc: add memdup
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Reviewed-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27762>
This commit is contained in:
committed by
Marge Bot
parent
d964f57a48
commit
66b00e2966
@@ -365,6 +365,18 @@ ralloc_set_destructor(const void *ptr, void(*destructor)(void *))
|
||||
info->destructor = destructor;
|
||||
}
|
||||
|
||||
void *
|
||||
ralloc_memdup(const void *ctx, const void *mem, size_t n)
|
||||
{
|
||||
void *ptr = ralloc_size(ctx, n);
|
||||
|
||||
if (unlikely(ptr == NULL))
|
||||
return NULL;
|
||||
|
||||
memcpy(ptr, mem, n);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
char *
|
||||
ralloc_strdup(const void *ctx, const char *str)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user