[U-Boot] [PATCH] Use correct kzalloc

Kyungmin Park kmpark at infradead.org
Mon Oct 6 04:20:28 CEST 2008


I'm not sure calloc returns all zero values.
Actually the calloc uses the __libc_alloc.

Instead of ambiguity, it uses the correct kzalloc.

Signed-off-by: Kyungmin Park <kyungmin.park at samsung.com>
---
diff --git a/include/linux/mtd/compat.h b/include/linux/mtd/compat.h
index 9036b74..840de4c 100644
--- a/include/linux/mtd/compat.h
+++ b/include/linux/mtd/compat.h
@@ -18,7 +18,12 @@
 #define KERN_DEBUG
 
 #define kmalloc(size, flags)	malloc(size)
-#define kzalloc(size, flags)	calloc(size, 1)
+#define kzalloc(size, flags)	({					\
+	void *__ret = malloc(size);					\
+	if (__ret)							\
+		memset(__ret, 0, size);					\
+	__ret;								\
+})
 #define vmalloc(size)			malloc(size)
 #define kfree(ptr)				free(ptr)
 #define vfree(ptr)				free(ptr)


More information about the U-Boot mailing list