* [U-Boot] [PATCH] Use correct kzalloc
@ 2008-10-06 2:20 Kyungmin Park
2008-10-06 7:28 ` Wolfgang Denk
0 siblings, 1 reply; 2+ messages in thread
From: Kyungmin Park @ 2008-10-06 2:20 UTC (permalink / raw)
To: u-boot
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@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)
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [U-Boot] [PATCH] Use correct kzalloc
2008-10-06 2:20 [U-Boot] [PATCH] Use correct kzalloc Kyungmin Park
@ 2008-10-06 7:28 ` Wolfgang Denk
0 siblings, 0 replies; 2+ messages in thread
From: Wolfgang Denk @ 2008-10-06 7:28 UTC (permalink / raw)
To: u-boot
Dear Kyungmin Park,
In message <20081006022028.GA5522@july> you wrote:
> I'm not sure calloc returns all zero values.
Why aren't you sure? Check the code...
> Actually the calloc uses the __libc_alloc.
Ooops? What exactly are you talking about?
It makes no sense to reinvent the wheel here.
If calloc() should have a problem (which I don't believe) it needs to
be fixed.
NAK for this patch.
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
The human mind ordinarily operates at only ten percent of its
capacity. The rest is overhead for the operating system.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-10-06 7:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-06 2:20 [U-Boot] [PATCH] Use correct kzalloc Kyungmin Park
2008-10-06 7:28 ` Wolfgang Denk
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox