[PATCH 01/12] string: define new memdup_array
Ahmad Fatoum
a.fatoum at pengutronix.de
Sun Jan 30 23:57:14 PST 2022
This will come in handy later for duplicating parent arrays when doing
clock registration.
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
include/linux/string.h | 3 +++
1 file changed, 3 insertions(+)
diff --git a/include/linux/string.h b/include/linux/string.h
index 3da174116a92..ae5e5bca8d24 100644
--- a/include/linux/string.h
+++ b/include/linux/string.h
@@ -5,6 +5,7 @@
#include <linux/types.h> /* for size_t */
#include <linux/stddef.h> /* for NULL */
+#include <linux/overflow.h> /* for array_size */
#ifdef __cplusplus
extern "C" {
@@ -133,6 +134,8 @@ static inline const char *kbasename(const char *path)
void *memdup(const void *, size_t);
+#define memdup_array(arr, count) memdup(arr, array_size(count, sizeof(*arr)));
+
static inline void *kmemdup(const void *src, size_t len, gfp_t gfp)
{
return memdup(src, len);
--
2.30.2
More information about the barebox
mailing list