[Sheepdog] [PATCH] use calloc instead of malloc + memset

MORITA Kazutaka morita.kazutaka at lab.ntt.co.jp
Thu Apr 22 19:37:20 CEST 2010


This also silences make check warnings.

Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
 include/util.h |   11 ++++-------
 1 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/include/util.h b/include/util.h
index b107e30..2dccd16 100644
--- a/include/util.h
+++ b/include/util.h
@@ -48,12 +48,9 @@ static inline int after(uint32_t seq1, uint32_t seq2)
 	(void) (&_x == &_y);		\
 	_x > _y ? _x : _y; })
 
-#define zalloc(size)			\
-({					\
-	void *ptr = malloc(size);	\
-	if (ptr)			\
-		memset(ptr, 0, size);	\
-	ptr;				\
-})
+static inline void *zalloc(size_t size)
+{
+	return calloc(1, size);
+}
 
 #endif
-- 
1.5.6.5




More information about the sheepdog mailing list