From: Luca Boccassi Date: Sat, 12 Aug 2023 22:14:13 +0000 (+0100) Subject: efi: add xmemdup X-Git-Tag: v255-rc1~289^2~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3e5a499009df048a553a8d01358a1b59fb04aa15;p=thirdparty%2Fsystemd.git efi: add xmemdup --- diff --git a/src/boot/efi/util.h b/src/boot/efi/util.h index 2f8c96d0ac6..25f35d2b5d7 100644 --- a/src/boot/efi/util.h +++ b/src/boot/efi/util.h @@ -58,6 +58,11 @@ static inline void *xrealloc(void *p, size_t old_size, size_t new_size) { return t; } +_malloc_ _alloc_(2) _returns_nonnull_ _warn_unused_result_ +static inline void* xmemdup(const void *p, size_t l) { + return memcpy(xmalloc(l), p, l); +} + #define xnew(type, n) ((type *) xmalloc_multiply(sizeof(type), (n))) typedef struct {