From 3e5a499009df048a553a8d01358a1b59fb04aa15 Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Sat, 12 Aug 2023 23:14:13 +0100 Subject: [PATCH] efi: add xmemdup --- src/boot/efi/util.h | 5 +++++ 1 file changed, 5 insertions(+) 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 { -- 2.47.3