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

From: Takashi Iwai
Date: Fri Jun 11 2004 - 05:12:55 EST


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
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/