diff options
| author | Craig Barnes <craigbarnes@protonmail.com> | 2024-03-16 20:28:10 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2024-03-17 11:31:02 +0000 |
| commit | e8b04e0e2c9e8a4f825193b907d04c3b3165a842 (patch) | |
| tree | e09c19881361236101249e846d7ac8618ca4baab /xmalloc.h | |
| parent | main/config: replace some uses of xasprintf() with xstrjoin() (diff) | |
xmalloc: add xmemdup() and use to replace some uses of xmalloc+memcpy
Diffstat (limited to 'xmalloc.h')
| -rw-r--r-- | xmalloc.h | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -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) { |
