xmalloc: add xmemdup() and use to replace some uses of xmalloc+memcpy

This commit is contained in:
Craig Barnes 2024-03-16 20:28:10 +00:00 committed by Daniel Eklöf
parent 853be450bb
commit e8b04e0e2c
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
4 changed files with 14 additions and 18 deletions

View file

@ -18,6 +18,12 @@ char *xasprintf(const char *format, ...) PRINTF(1) XMALLOC;
char *xvasprintf(const char *format, va_list va) VPRINTF(1) XMALLOC;
char32_t *xc32dup(const char32_t *str) XSTRDUP;
static inline void *
xmemdup(const void *ptr, size_t size)
{
return memcpy(xmalloc(size), ptr, size);
}
static inline char *
xstrjoin(const char *s1, const char *s2)
{