diff options
author | Pekka J Enberg <penberg@cs.Helsinki.FI> | 2005-09-06 15:18:31 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-09-07 16:57:45 -0700 |
commit | dd3927105b6f65afb7dac17682172cdfb86d3f00 (patch) | |
tree | 5cf282aff500cad23b9d7e13dc19b2b2d31e1ce6 /include | |
parent | 640e803376b9c4072f69fec42e304c974a631298 (diff) | |
download | kernel-crypto-dd3927105b6f65afb7dac17682172cdfb86d3f00.tar.gz kernel-crypto-dd3927105b6f65afb7dac17682172cdfb86d3f00.tar.xz kernel-crypto-dd3927105b6f65afb7dac17682172cdfb86d3f00.zip |
[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>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/slab.h | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/include/linux/slab.h b/include/linux/slab.h index 80b2dfde2e8..42a6bea58af 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -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 *); |