lkml.org 
[lkml]   [2012]   [Feb]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH RFC v2] slab: introduce kmalloc_array
On Thu, 9 Feb 2012 23:47:42 +0100 (CET)
Jesper Juhl <jj@chaosbits.net> wrote:

> > -static inline void *kcalloc(size_t n, size_t size, gfp_t flags)
> > +static inline void *kmalloc_array(size_t n, size_t size, gfp_t flags)
> > {
> > if (size != 0 && n > ULONG_MAX / size)
> > return NULL;
> > - return __kmalloc(n * size, flags | __GFP_ZERO);
> > + return __kmalloc(n * size, flags);
> > +}
> > +
> > +/**
> > + * 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 (see kmalloc).
> > + */
> > +static inline void *kcalloc(size_t n, size_t size, gfp_t flags)
> > +{
> > + return kmalloc_array(n, size, flags | __GFP_ZERO);
> > }
> >
> > #if !defined(CONFIG_NUMA) && !defined(CONFIG_SLOB)
> >
>
> Does this want adding to Documentation/CodingStyle "Chapter 14: Allocating
> memory" ?

Spose so. We could possibly cook up a checkpatch rule too ;)

<gad, CodingStyle has 18 chapters and an appendix??>



\
 
 \ /
  Last update: 2012-02-10 00:09    [from the cache]
©2003-2011 Jasper Spaans