[PATCH 1/2] macro: add newdup macro, equivalent of new + memdup but type-safe

Frederic Crozat fcrozat at suse.com
Thu Mar 29 08:53:41 PDT 2012


---
 src/macro.h |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/src/macro.h b/src/macro.h
index 19f259e..5e1106f 100644
--- a/src/macro.h
+++ b/src/macro.h
@@ -137,6 +137,7 @@ static inline size_t ALIGN_TO(size_t l, size_t ali) {
 
 #define memzero(x,l) (memset((x), 0, (l)))
 #define zero(x) (memzero(&(x), sizeof(x)))
+#define newdup(t, p, n) ((t*)memdup(p,sizeof(t)*(n)))
 
 #define char_array_0(x) x[sizeof(x)-1] = 0;
 
-- 
1.7.7




More information about the systemd-devel mailing list