Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S263185AbUFKKLm (ORCPT ); Fri, 11 Jun 2004 06:11:42 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S263781AbUFKKLm (ORCPT ); Fri, 11 Jun 2004 06:11:42 -0400 Received: from cantor.suse.de ([195.135.220.2]:54438 "EHLO Cantor.suse.de") by vger.kernel.org with ESMTP id S263185AbUFKKLk (ORCPT ); Fri, 11 Jun 2004 06:11:40 -0400 Date: Fri, 11 Jun 2004 12:09:40 +0200 Message-ID: From: Takashi Iwai To: Pekka Enberg Cc: Arjan van de Ven , Chris Wright , linux-kernel@vger.kernel.org Subject: Re: [PATCH] ALSA: Remove subsystem-specific malloc (1/8) In-Reply-To: <1086815269.13026.76.camel@cherry> References: <200406082124.i58LOuOL016163@melkki.cs.helsinki.fi> <20040609113455.U22989@build.pdx.osdl.net> <1086812001.13026.63.camel@cherry> <1086812486.2810.21.camel@laptop.fenrus.com> <1086814663.13026.70.camel@cherry> <20040609205944.GA21150@devserv.devel.redhat.com> <1086815269.13026.76.camel@cherry> User-Agent: Wanderlust/2.10.1 (Watching The Wheels) SEMI/1.14.5 (Awara-Onsen) FLIM/1.14.5 (Demachiyanagi) APEL/10.6 MULE XEmacs/21.4 (patch 13) (Rational FORTRAN) (i386-suse-linux) MIME-Version: 1.0 (generated by SEMI 1.14.5 - "Awara-Onsen") Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1108 Lines: 39 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@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/