Re: [PATCH] ALSA: Remove subsystem-specific malloc (1/8)

Takashi Iwai
2004-06-11T10:11:42Z

At Thu, 10 Jun 2004 00:07:49 +0300,
Pekka Enberg wrote:
>
> On Wed, Jun 09, 2004 at 11:57:43PM +0300, Pekka Enberg wrote:
> > > +void *kcalloc(size_t n, size_t size, int flags)
> > > +{
> > > + if (n != 0 && size > INT_MAX / n)
> > > + return NULL;
> > > +
> > > + void *ret = kmalloc(n * size, flags);
> > > + if (ret)
> > > + memset(ret, 0, n * size);
> > > + return ret;
> > > +}
>
> On Wed, 2004-06-09 at 23:59, Arjan van de Ven wrote:
> > ok I like it ;)
> >
> > only question is what n==0 means, might as well short-circuit that but it's
> > optional
>
> Nah, I don't see the point. Now if I can only convince the ALSA guys to
> switch to this... =)

I don't think the shortcut is necessary, too.
By calling kmalloc with 0, the same behavior as kmalloc is
guaranteed.

BTW, I agree with conversion to the standard calloc() style :)

thanks,

Takashi