aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/slab.h17
1 files changed, 14 insertions, 3 deletions
diff --git a/include/linux/slab.h b/include/linux/slab.h
index 573c809c33d9..a595dce6b0c7 100644
--- a/include/linux/slab.h
+++ b/include/linux/slab.h
@@ -190,7 +190,7 @@ size_t ksize(const void *);
190#endif 190#endif
191 191
192/** 192/**
193 * kcalloc - allocate memory for an array. The memory is set to zero. 193 * kmalloc_array - allocate memory for an array.
194 * @n: number of elements. 194 * @n: number of elements.
195 * @size: element size. 195 * @size: element size.
196 * @flags: the type of memory to allocate. 196 * @flags: the type of memory to allocate.
@@ -240,11 +240,22 @@ size_t ksize(const void *);
240 * for general use, and so are not documented here. For a full list of 240 * for general use, and so are not documented here. For a full list of
241 * potential flags, always refer to linux/gfp.h. 241 * potential flags, always refer to linux/gfp.h.
242 */ 242 */
243static inline void *kcalloc(size_t n, size_t size, gfp_t flags) 243static inline void *kmalloc_array(size_t n, size_t size, gfp_t flags)
244{ 244{
245 if (size != 0 && n > ULONG_MAX / size) 245 if (size != 0 && n > ULONG_MAX / size)
246 return NULL; 246 return NULL;
247 return __kmalloc(n * size, flags | __GFP_ZERO); 247 return __kmalloc(n * size, flags);
248}
249
250/**
251 * kcalloc - allocate memory for an array. The memory is set to zero.
252 * @n: number of elements.
253 * @size: element size.
254 * @flags: the type of memory to allocate (see kmalloc).
255 */
256static inline void *kcalloc(size_t n, size_t size, gfp_t flags)
257{
258 return kmalloc_array(n, size, flags | __GFP_ZERO);
248} 259}
249 260
250#if !defined(CONFIG_NUMA) && !defined(CONFIG_SLOB) 261#if !defined(CONFIG_NUMA) && !defined(CONFIG_SLOB)