[igt-dev] [PATCH i-g-t 1/7] lib: Introduce igt_memdup()
Ville Syrjala
ville.syrjala at linux.intel.com
Wed Oct 13 12:59:43 UTC 2021
From: Ville Syrjälä <ville.syrjala at linux.intel.com>
Provide a helper to do the malloc()+memcpy() in one swift blow.
Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
---
lib/igt_aux.c | 11 +++++++++++
lib/igt_aux.h | 2 ++
2 files changed, 13 insertions(+)
diff --git a/lib/igt_aux.c b/lib/igt_aux.c
index 1217f5e88094..2445e483e210 100644
--- a/lib/igt_aux.c
+++ b/lib/igt_aux.c
@@ -1527,3 +1527,14 @@ uint64_t vfs_file_max(void)
}
return max;
}
+
+void *igt_memdup(const void *ptr, size_t len)
+{
+ void *dup;
+
+ dup = malloc(len);
+ if (dup)
+ memcpy(dup, ptr, len);
+
+ return dup;
+}
diff --git a/lib/igt_aux.h b/lib/igt_aux.h
index 30b175d70d8b..a3c477abcd86 100644
--- a/lib/igt_aux.h
+++ b/lib/igt_aux.h
@@ -324,4 +324,6 @@ void igt_lsof(const char *dpath);
uint64_t vfs_file_max(void);
+void *igt_memdup(const void *ptr, size_t len);
+
#endif /* IGT_AUX_H */
--
2.32.0
More information about the igt-dev
mailing list