[PATCH] introduce and use kzalloc

This patch introduces a kzalloc wrapper and converts kernel/ to use it.  It
saves a little program text.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
Signed-off-by: Adrian Bunk <bunk@stusta.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
Pekka J Enberg
2005-09-06 15:18:31 -07:00
committed by Linus Torvalds
parent 640e803376
commit dd3927105b
7 changed files with 27 additions and 23 deletions

View File

@@ -99,7 +99,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 *);