From: Adrian Bunk kcalloc() doesn't do much more than calling kzalloc(), and gcc has better optimizing opportunities when it's inlined. The result of this patch with a fulll kernel compile (roughly equivalent to "make allyesconfig") shows a minimal size improvement: text data bss dec hex filename 25864955 5891214 2012840 33769009 2034631 vmlinux-before 25864635 5891206 2012840 33768681 20344e9 vmlinux-staticinline Signed-off-by: Adrian Bunk Acked-by: Pekka Enberg Signed-off-by: Andrew Morton --- include/linux/slab.h | 15 ++++++++++++++- mm/slab.c | 14 -------------- 2 files changed, 14 insertions(+), 15 deletions(-) diff -puN include/linux/slab.h~introduce-and-use-kzalloc-make-kcalloc-a-static-inline include/linux/slab.h --- devel/include/linux/slab.h~introduce-and-use-kzalloc-make-kcalloc-a-static-inline 2005-08-08 23:28:22.000000000 -0700 +++ devel-akpm/include/linux/slab.h 2005-08-08 23:28:22.000000000 -0700 @@ -103,8 +103,21 @@ found: return __kmalloc(size, flags); } -extern void *kcalloc(size_t, size_t, unsigned int __nocast); extern void *kzalloc(size_t, unsigned int __nocast); + +/** + * kcalloc - allocate memory for an array. The memory is set to zero. + * @n: number of elements. + * @size: element size. + * @flags: the type of memory to allocate. + */ +static inline void *kcalloc(size_t n, size_t size, unsigned int __nocast flags) +{ + if (n != 0 && size > INT_MAX / n) + return NULL; + return kzalloc(n * size, flags); +} + extern void kfree(const void *); extern unsigned int ksize(const void *); diff -puN mm/slab.c~introduce-and-use-kzalloc-make-kcalloc-a-static-inline mm/slab.c --- devel/mm/slab.c~introduce-and-use-kzalloc-make-kcalloc-a-static-inline 2005-08-08 23:28:22.000000000 -0700 +++ devel-akpm/mm/slab.c 2005-08-08 23:28:22.000000000 -0700 @@ -2571,20 +2571,6 @@ void *kzalloc(size_t size, unsigned int EXPORT_SYMBOL(kzalloc); /** - * kcalloc - allocate memory for an array. The memory is set to zero. - * @n: number of elements. - * @size: element size. - * @flags: the type of memory to allocate. - */ -void *kcalloc(size_t n, size_t size, unsigned int __nocast flags) -{ - if (n != 0 && size > INT_MAX / n) - return NULL; - return kzalloc(n * size, flags); -} -EXPORT_SYMBOL(kcalloc); - -/** * kfree - free previously allocated memory * @objp: pointer returned by kmalloc. * _