[CRIU] [PATCH 4/9] xmalloc: Add xmemdup helper
Cyrill Gorcunov
gorcunov at openvz.org
Thu Dec 17 01:14:12 PST 2015
Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
include/xmalloc.h | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/include/xmalloc.h b/include/xmalloc.h
index 0331c9b7bc39..e5ce279fab1a 100644
--- a/include/xmalloc.h
+++ b/include/xmalloc.h
@@ -33,6 +33,14 @@
__ret; \
})
+#define xmemdup(ptr, size) \
+ ({ \
+ void *new = xmalloc(size); \
+ if (new) \
+ memcpy(new, ptr, size); \
+ new; \
+ })
+
#define memzero_p(p) memset(p, 0, sizeof(*p))
#define memzero(p, size) memset(p, 0, size)
--
2.5.0
More information about the CRIU
mailing list